Open History to see the last commit
1---
2title: TanStack Devtools React Adapter
3id: adapter
4---
5β
6If you are using TanStack Devtools in a React application, we recommend using the React Adapter. The React Adapter provides a set of easy-to-use hooks on top of the core Devtools utilities. If you find yourself wanting to use the core Devtools classes/functions directly, the React Adapter will also re-export everything from the core package.
7β
8## Installation
9β
10```sh
11npm install @tanstack/react-devtools
12```
13β
14## Component: TanStackDevtools
15β
16The main React component for rendering devtools. It accepts a single props object of type `TanStackDevtoolsReactInit`:
17β
18| Prop | Type | Description |
19| --- | --- | --- |
20| `plugins` | `TanStackDevtoolsReactPlugin[]` | Array of plugins to display in the devtools panel |
21| `config` | `TanStackDevtoolsReactConfig` | Devtools UI configuration (position, hotkeys, theme, custom trigger, etc.) |
22| `eventBusConfig` | `ClientEventBusConfig` | Event bus connection settings for communicating with the server bus |
23β
24## Plugin Type: TanStackDevtoolsReactPlugin
25β
26Each plugin describes a tab in the devtools panel:
27β
28```ts
29type PluginRender =
30 | JSX.Element
31 | ((el: HTMLElement, theme: 'dark' | 'light') => JSX.Element)
32β
33type TanStackDevtoolsReactPlugin = {
34 id?: string
35 name: string | PluginRender
36 render: PluginRender
37 defaultOpen?: boolean
38}
39```
40β
41- **`render`** can be a JSX element (simplest -- just pass `<YourPanel />`) or a function that receives the container element and current theme. The function form is useful when you need to access the raw DOM element or respond to theme changes.
42- **`name`** works the same way -- use a string for plain text, or JSX / a function for custom tab titles.
43- **`id`** is an optional unique identifier. If omitted, it is generated from the name.
44- **`defaultOpen`** marks the plugin as initially active when no other plugins are open.
45β
46## Usage Example
47β
48```tsx
49import { TanStackDevtools } from '@tanstack/react-devtools'
50import { ReactQueryDevtoolsPanel } from '@tanstack/react-query-devtools'
51β
52function App() {
53 return (
54 <>
55 <YourApp />
56 <TanStackDevtools
57 config={{ position: 'bottom-right', hideUntilHover: true }}
58 eventBusConfig={{ connectToServerBus: true }}
59 plugins={[
60 {
61 name: 'TanStack Query',
62 render: <ReactQueryDevtoolsPanel />,
63 defaultOpen: true,
64 },
65 ]}
66 />
67 </>
68 )
69}
70```
71β
72## RSC Compatibility
73β
74The adapter includes a `'use client'` directive at the top of its entry file, making it compatible with React Server Components. You can import it directly in your client components without needing to add your own `'use client'` boundary.
75β
76## Exports
77β
78The `@tanstack/react-devtools` package exports:
79β
80- **`TanStackDevtools`** -- the main component
81- **`TanStackDevtoolsReactPlugin`** -- type for plugin objects
82- **`TanStackDevtoolsReactInit`** -- type for the component's props