Skip to content
Source
Sign inSign up
TanStack/query
Open History to see the last commit

devtools.md

78 lines3.1 KB

1---
2id: devtools
3title: Devtools
4---
5​
6Wave your hands in the air and shout hooray because React Query comes with dedicated devtools! πŸ₯³
7​
8When you begin your React Query journey, you'll want these devtools by your side. They help visualize all of the inner workings of React Query and will likely save you hours of debugging if you find yourself in a pinch!
9​
10> Please note that for now, the devtools **do not support React Native**. If you would like to help us make the devtools platform agnostic, please let us know!
11​
12## Import the Devtools
13​
14The devtools are bundle split into the `react-query/devtools` package. No need to install anything extra, just:
15​
16```js
17import { ReactQueryDevtools } from 'react-query/devtools'
18```
19​
20By default, React Query Devtools are only included in bundles when `process.env.NODE_ENV === 'development'`, so you don't need to worry about excluding them during a production build.
21## Floating Mode
22​
23Floating Mode will mount the devtools as a fixed, floating element in your app and provide a toggle in the corner of the screen to show and hide the devtools. This toggle state will be stored and remembered in localStorage across reloads.
24​
25Place the following code as high in your React app as you can. The closer it is to the root of the page, the better it will work!
26​
27```js
28import { ReactQueryDevtools } from 'react-query/devtools'
29​
30function App() {
31 return (
32 <QueryClientProvider client={queryClient}>
33 {/* The rest of your application */}
34 <ReactQueryDevtools initialIsOpen={false} />
35 </QueryClientProvider>
36 )
38```
39​
40### Options
41​
42- `initialIsOpen: Boolean`
43 - Set this `true` if you want the dev tools to default to being open
44- `panelProps: PropsObject`
45 - Use this to add props to the panel. For example, you can add `className`, `style` (merge and override default style), etc.
46- `closeButtonProps: PropsObject`
47 - Use this to add props to the close button. For example, you can add `className`, `style` (merge and override default style), `onClick` (extend default handler), etc.
48- `toggleButtonProps: PropsObject`
49 - Use this to add props to the toggle button. For example, you can add `className`, `style` (merge and override default style), `onClick` (extend default handler), etc.
50- `position?: "top-left" | "top-right" | "bottom-left" | "bottom-right"`
51 - Defaults to `bottom-left`
52 - The position of the React Query logo to open and close the devtools panel
53​
54## Embedded Mode
55​
56Embedded Mode will embed the devtools as a regular component in your application. You can style it however you'd like after that!
57​
58```js
59import { ReactQueryDevtoolsPanel } from 'react-query/devtools'
60​
61function App() {
62 return (
63 <QueryClientProvider client={queryClient}>
64 {/* The rest of your application */}
65 <ReactQueryDevtoolsPanel style={styles} className={className} />
66 </QueryClientProvider>
67 )
69```
70​
71### Options
72​
73Use these options to style the dev tools.
74​
75- `style: StyleObject`
76 - The standard React style object used to style a component with inline styles
77- `className: string`
78 - The standard React className property used to style a component with classes