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

configuration.md

166 lines3.7 KB

1---
2title: Configuration
3id: configuration
4---
5​
6Both TanStack `DevTools` and `EventClient` can be configured.
7​
8> [!IMPORTANT]
9> All configuration is optional unless marked (required)
10​
11## Devtools Component Configuration
12​
13The `Devtools` component has two configuration props, regardless of Frameworks these are the same.
14​
15- `config` - Configuration for the devtool panel and interaction with it.
16- `eventBusConfig` - Configuration for the event bus.
17​
18The `config` object is mainly focused around user interaction with the devtools panel and accepts the following properties:
19​
20- `defaultOpen` - If the devtools are open by default
21​
22```ts
23{ defaultOpen: boolean }
24```
25​
26- `hideUntilHover` - Hides the TanStack devtools trigger until hovered
27​
28```ts
29{ hideUntilHover: boolean }
30```
31​
32- `position` - The position of the TanStack devtools trigger
33​
34```ts
35{ position: 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right' | 'middle-left' | 'middle-right' }
36```
37​
38- `panelLocation` - The location of the devtools panel
39​
40```ts
41{ panelLocation: 'top' | 'bottom' }
42```
43​
44- `openHotkey` - The hotkey set to open the devtools
45​
46```ts
47type ModifierKey = 'Alt' | 'Control' | 'Meta' | 'Shift' | 'CtrlOrMeta';
48type KeyboardKey = ModifierKey | (string & {});
49​
50{ openHotkey: Array<KeyboardKey> }
51```
52​
53- `inspectHotkey` - The hotkey set to open the source inspector
54​
55```ts
56type ModifierKey = 'Alt' | 'Control' | 'Meta' | 'Shift' | 'CtrlOrMeta';
57type KeyboardKey = ModifierKey | (string & {});
58​
59{ inspectHotkey: Array<KeyboardKey> }
60```
61​
62- `requireUrlFlag` - Requires a flag present in the url to enable devtools
63​
64```ts
65{ requireUrlFlag: boolean }
66```
67​
68- `triggerImage` - The image used for the dev tools trigger
69​
70```ts
71{ triggerImage: string }
72```
73​
74- `urlFlag` - The required flag that must be present in the url to enable devtools.
75​
76```ts
77{ urlFlag: string }
78```
79​
80The `eventBusConfig` is configuration for the back bone of the devtools, the `EventClient`, and accepts the following properties:
81​
82- `debug` - Enables debug mode for the EventBus
83​
84```ts
85{ debug: boolean }
86```
87​
88- `connectToServerBus` - Optional flag to indicate if the devtools server event bus is available to connect to
89​
90```ts
91{ connectToServerBus: boolean }
92```
93​
94- `port` - The port at which the client connects to the devtools server event bus
95​
96```ts
97{ port: number }
98```
99​
100Put together here is an example in react:
101​
102```tsx
103import { StrictMode } from 'react'
104import { createRoot } from 'react-dom/client'
105import { FormDevtools } from '@tanstack/react-form'
106​
107import { TanStackDevtools } from '@tanstack/react-devtools'
108​
109import App from './App'
110​
111createRoot(document.getElementById('root')!).render(
112 <StrictMode>
113 <App />
114​
115 <TanStackDevtools
116 config={{ hideUntilHover: true }}
117 eventBusConfig={{ debug: true }}
118 plugins={[
119 {
120 name: 'TanStack Form',
121 render: <FormDevtools />,
122 defaultOpen: true,
123 },
124 ]}
125 />
126 </StrictMode>,
128​
129```
130​
131## EventClient Configuration
132​
133Configuration for the `EventClient` is as follows
134​
135- `pluginId` (required) - The plugin identifier used by the event bus to direct events to listeners
136​
137```ts
138{ pluginId: string }
139```
140​
141- `debug` - Enables debug mode for the EventClient
142​
143```ts
144{ debug: boolean }
145```
146​
147Put together the `EventClient` configuration looks like:
148​
149```tsx
150import { EventClient } from '@tanstack/devtools-event-client'
151​
152type EventMap = {
153 'custom-state': { state: string }
155​
156class customEventClient extends EventClient<EventMap> {
157 constructor() {
158 super({
159 debug: true,
160 pluginId: 'custom-devtools',
161 })
162 }
164```
165​
166More information about EventClient configuration can be found in our [custom-plugins example](https://tanstack.com/devtools/latest/docs/framework/react/examples/custom-devtools)