* docs: add documentation redesign design document Comprehensive plan for restructuring TanStack Devtools documentation with layered architecture approach: Getting Started, Concepts, Guides, API Reference, and Examples sections. Adds 11 new pages including architecture overview, event system deep-dive, Vue framework support, and plugin building guides. * docs: add documentation implementation plan 18-task plan covering: navigation restructure, 4 new Concepts pages (architecture, event system, plugin lifecycle, source inspector), 3 new Guides (custom plugins, devtools-utils, bidirectional comms), Vue framework support, Solid custom plugins, and updates to existing pages including overview, quick-start, installation, and React adapter. * docs: restructure navigation with Concepts and Guides sections, add Vue * docs: expand overview with package map and architecture diagram * docs: add all framework examples to quick start * docs: add Vue and Preact installation instructions * docs: add architecture overview page * docs: add event system concepts page * docs: add plugin lifecycle concepts page * docs: add source inspector concepts page * docs: add framework-agnostic custom plugin building guide * docs: add devtools-utils guide for plugin factory helpers * docs: add bidirectional communication guide * docs: add Vue basic setup and adapter pages * docs: add Vue and Solid custom plugins guides * docs: replace TODO in React adapter with actual content * docs: expand Vite plugin features documentation * docs: fix event map key convention, typos, and internal link extensions - Event map keys should be suffix-only (e.g., 'state-update'), not prefixed with pluginId. EventClient prepends pluginId automatically. Fixed across all custom plugin guides and concept pages. - Fix enabled:false docs in event-system.md (emit is a no-op, not internal dispatch) - Fix double "the the" typo in installation.md - Remove .md extensions from internal doc links for consistency - Fix event map key in configuration.md example * docs: remove internal plan files * docs: replace ASCII diagrams with mermaid in architecture overview * docs: add mermaid diagrams across all documentation pages - overview.md: architecture layer diagram - event-system.md: connection lifecycle state diagram - plugin-lifecycle.md: mount sequence flowchart + portal pattern diagram - source-inspector.md: inspection flow diagram - building-custom-plugins.md: plugin architecture overview - bidirectional-communication.md: two-way flow + time travel sequence diagram - vite-plugin.md: sub-plugin overview diagram
2.9 KiB
| title | id |
|---|---|
| TanStack Devtools React Adapter | adapter |
If 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.
Installation
npm install @tanstack/react-devtools
Component: TanStackDevtools
The main React component for rendering devtools. It accepts a single props object of type TanStackDevtoolsReactInit:
| Prop | Type | Description |
|---|---|---|
plugins |
TanStackDevtoolsReactPlugin[] |
Array of plugins to display in the devtools panel |
config |
TanStackDevtoolsReactConfig |
Devtools UI configuration (position, hotkeys, theme, custom trigger, etc.) |
eventBusConfig |
ClientEventBusConfig |
Event bus connection settings for communicating with the server bus |
Plugin Type: TanStackDevtoolsReactPlugin
Each plugin describes a tab in the devtools panel:
type PluginRender =
| JSX.Element
| ((el: HTMLElement, theme: 'dark' | 'light') => JSX.Element)
type TanStackDevtoolsReactPlugin = {
id?: string
name: string | PluginRender
render: PluginRender
defaultOpen?: boolean
}
rendercan 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.nameworks the same way -- use a string for plain text, or JSX / a function for custom tab titles.idis an optional unique identifier. If omitted, it is generated from the name.defaultOpenmarks the plugin as initially active when no other plugins are open.
Usage Example
import { TanStackDevtools } from '@tanstack/react-devtools'
import { ReactQueryDevtoolsPanel } from '@tanstack/react-query-devtools'
function App() {
return (
<>
<YourApp />
<TanStackDevtools
config={{ position: 'bottom-right', hideUntilHover: true }}
eventBusConfig={{ connectToServerBus: true }}
plugins={[
{
name: 'TanStack Query',
render: <ReactQueryDevtoolsPanel />,
defaultOpen: true,
},
]}
/>
</>
)
}
RSC Compatibility
The 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.
Exports
The @tanstack/react-devtools package exports:
TanStackDevtools-- the main componentTanStackDevtoolsReactPlugin-- type for plugin objectsTanStackDevtoolsReactInit-- type for the component's props