@tanstack/devtools 0.10.13 → 0.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/intent.js +20 -0
- package/dist/dev.js +1 -1
- package/dist/devtools/{W6LG6674.js → AKRRB3KC.js} +41 -8
- package/dist/devtools/{7Z2ESJHO.js → UZDPUP5E.js} +37 -7
- package/dist/index.d.ts +14 -6
- package/dist/index.js +1 -1
- package/dist/mount-impl/{EMNOPRXX.js → IGHTIX6Y.js} +1 -1
- package/dist/mount-impl/{Z6LKUI5N.js → YYPMJI4G.js} +1 -1
- package/dist/server.js +1 -1
- package/package.json +9 -4
- package/skills/devtools-app-setup/SKILL.md +359 -0
- package/skills/devtools-marketplace/SKILL.md +390 -0
- package/skills/devtools-plugin-panel/SKILL.md +429 -0
- package/skills/devtools-plugin-panel/references/panel-api.md +136 -0
- package/skills/devtools-production/SKILL.md +459 -0
- package/src/components/tab-content.tsx +9 -5
- package/src/context/devtools-context.tsx +7 -9
- package/src/context/devtools-store.ts +3 -2
- package/src/devtools.tsx +9 -1
- package/src/index.ts +2 -0
- package/src/styles/use-styles.ts +0 -1
- package/src/tabs/index.tsx +1 -1
- package/src/tabs/plugin-registry.ts +18 -0
- package/src/tabs/plugins-tab.tsx +9 -4
|
@@ -0,0 +1,359 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: devtools-app-setup
|
|
3
|
+
description: >
|
|
4
|
+
Install TanStack Devtools, pick framework adapter (React/Vue/Solid/Preact),
|
|
5
|
+
register plugins via plugins prop, configure shell (position, hotkeys, theme,
|
|
6
|
+
hideUntilHover, requireUrlFlag, eventBusConfig). TanStackDevtools component,
|
|
7
|
+
defaultOpen, localStorage persistence.
|
|
8
|
+
type: core
|
|
9
|
+
library: '@tanstack/devtools'
|
|
10
|
+
library_version: '0.10.12'
|
|
11
|
+
sources:
|
|
12
|
+
- docs/quick-start.md
|
|
13
|
+
- docs/installation.md
|
|
14
|
+
- docs/configuration.md
|
|
15
|
+
- docs/overview.md
|
|
16
|
+
- packages/devtools/src/context/devtools-store.ts
|
|
17
|
+
- packages/vue-devtools/src/types.ts
|
|
18
|
+
- packages/react-devtools/src/devtools.tsx
|
|
19
|
+
---
|
|
20
|
+
|
|
21
|
+
# TanStack Devtools App Setup
|
|
22
|
+
|
|
23
|
+
## Setup
|
|
24
|
+
|
|
25
|
+
### React (primary)
|
|
26
|
+
|
|
27
|
+
Install as dev dependencies:
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
npm install -D @tanstack/react-devtools @tanstack/devtools-vite
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
Mount `TanStackDevtools` at the root of your application:
|
|
34
|
+
|
|
35
|
+
```tsx
|
|
36
|
+
import { StrictMode } from 'react'
|
|
37
|
+
import { createRoot } from 'react-dom/client'
|
|
38
|
+
import { TanStackDevtools } from '@tanstack/react-devtools'
|
|
39
|
+
import App from './App'
|
|
40
|
+
|
|
41
|
+
createRoot(document.getElementById('root')!).render(
|
|
42
|
+
<StrictMode>
|
|
43
|
+
<App />
|
|
44
|
+
<TanStackDevtools />
|
|
45
|
+
</StrictMode>,
|
|
46
|
+
)
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
Add plugins via the `plugins` prop. Each plugin needs `name` (string) and `render` (JSX element or render function):
|
|
50
|
+
|
|
51
|
+
```tsx
|
|
52
|
+
import { TanStackDevtools } from '@tanstack/react-devtools'
|
|
53
|
+
import { ReactQueryDevtoolsPanel } from '@tanstack/react-query-devtools'
|
|
54
|
+
import { TanStackRouterDevtoolsPanel } from '@tanstack/react-router-devtools'
|
|
55
|
+
;<TanStackDevtools
|
|
56
|
+
plugins={[
|
|
57
|
+
{
|
|
58
|
+
name: 'TanStack Query',
|
|
59
|
+
render: <ReactQueryDevtoolsPanel />,
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
name: 'TanStack Router',
|
|
63
|
+
render: <TanStackRouterDevtoolsPanel />,
|
|
64
|
+
},
|
|
65
|
+
]}
|
|
66
|
+
/>
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
### Vue
|
|
70
|
+
|
|
71
|
+
```bash
|
|
72
|
+
npm install -D @tanstack/vue-devtools
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
Vue uses `component` (not `render`) in plugin definitions. This is the `TanStackDevtoolsVuePlugin` type:
|
|
76
|
+
|
|
77
|
+
```vue
|
|
78
|
+
<script setup lang="ts">
|
|
79
|
+
import { TanStackDevtools } from '@tanstack/vue-devtools'
|
|
80
|
+
import type { TanStackDevtoolsVuePlugin } from '@tanstack/vue-devtools'
|
|
81
|
+
import { VueQueryDevtoolsPanel } from '@tanstack/vue-query-devtools'
|
|
82
|
+
|
|
83
|
+
const plugins: TanStackDevtoolsVuePlugin[] = [
|
|
84
|
+
{ name: 'Vue Query', component: VueQueryDevtoolsPanel },
|
|
85
|
+
]
|
|
86
|
+
</script>
|
|
87
|
+
|
|
88
|
+
<template>
|
|
89
|
+
<App />
|
|
90
|
+
<TanStackDevtools :plugins="plugins" />
|
|
91
|
+
</template>
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
The Vite plugin (`@tanstack/devtools-vite`) is optional for Vue but recommended for enhanced console logs and go-to-source.
|
|
95
|
+
|
|
96
|
+
### Solid
|
|
97
|
+
|
|
98
|
+
```bash
|
|
99
|
+
npm install -D @tanstack/solid-devtools @tanstack/devtools-vite
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
```tsx
|
|
103
|
+
import { render } from 'solid-js/web'
|
|
104
|
+
import { TanStackDevtools } from '@tanstack/solid-devtools'
|
|
105
|
+
import { SolidQueryDevtoolsPanel } from '@tanstack/solid-query-devtools'
|
|
106
|
+
import App from './App'
|
|
107
|
+
|
|
108
|
+
render(
|
|
109
|
+
() => (
|
|
110
|
+
<>
|
|
111
|
+
<App />
|
|
112
|
+
<TanStackDevtools
|
|
113
|
+
plugins={[
|
|
114
|
+
{
|
|
115
|
+
name: 'TanStack Query',
|
|
116
|
+
render: <SolidQueryDevtoolsPanel />,
|
|
117
|
+
},
|
|
118
|
+
]}
|
|
119
|
+
/>
|
|
120
|
+
</>
|
|
121
|
+
),
|
|
122
|
+
document.getElementById('root')!,
|
|
123
|
+
)
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
### Preact
|
|
127
|
+
|
|
128
|
+
```bash
|
|
129
|
+
npm install -D @tanstack/preact-devtools @tanstack/devtools-vite
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
```tsx
|
|
133
|
+
import { render } from 'preact'
|
|
134
|
+
import { TanStackDevtools } from '@tanstack/preact-devtools'
|
|
135
|
+
import App from './App'
|
|
136
|
+
|
|
137
|
+
render(
|
|
138
|
+
<>
|
|
139
|
+
<App />
|
|
140
|
+
<TanStackDevtools
|
|
141
|
+
plugins={[
|
|
142
|
+
{
|
|
143
|
+
name: 'Your Plugin',
|
|
144
|
+
render: <YourPluginComponent />,
|
|
145
|
+
},
|
|
146
|
+
]}
|
|
147
|
+
/>
|
|
148
|
+
</>,
|
|
149
|
+
document.getElementById('root')!,
|
|
150
|
+
)
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
## Core Patterns
|
|
154
|
+
|
|
155
|
+
### Shell Configuration
|
|
156
|
+
|
|
157
|
+
Pass a `config` prop to `TanStackDevtools` to set initial shell behavior. These values are persisted to `localStorage` after first load and can be changed through the settings panel at runtime.
|
|
158
|
+
|
|
159
|
+
Storage keys used internally:
|
|
160
|
+
|
|
161
|
+
- `tanstack_devtools_settings` -- persisted settings
|
|
162
|
+
- `tanstack_devtools_state` -- persisted UI state (active tab, panel height, active plugins, persistOpen)
|
|
163
|
+
|
|
164
|
+
All config properties are optional. Defaults shown below:
|
|
165
|
+
|
|
166
|
+
```tsx
|
|
167
|
+
<TanStackDevtools
|
|
168
|
+
config={{
|
|
169
|
+
defaultOpen: false, // open panel on mount
|
|
170
|
+
hideUntilHover: false, // hide trigger until mouse hover
|
|
171
|
+
position: 'bottom-right', // trigger position: 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right' | 'middle-left' | 'middle-right'
|
|
172
|
+
panelLocation: 'bottom', // panel position: 'top' | 'bottom'
|
|
173
|
+
openHotkey: ['Control', '~'],
|
|
174
|
+
inspectHotkey: ['Shift', 'Alt', 'CtrlOrMeta'],
|
|
175
|
+
requireUrlFlag: false, // require URL param to show devtools
|
|
176
|
+
urlFlag: 'tanstack-devtools', // the URL param name when requireUrlFlag is true
|
|
177
|
+
theme: 'dark', // 'light' | 'dark' (defaults to system preference)
|
|
178
|
+
triggerHidden: false, // completely hide trigger (hotkey still works)
|
|
179
|
+
}}
|
|
180
|
+
/>
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
### Event Bus Configuration
|
|
184
|
+
|
|
185
|
+
The `eventBusConfig` prop configures the client-side event bus that plugins use for communication:
|
|
186
|
+
|
|
187
|
+
```tsx
|
|
188
|
+
<TanStackDevtools
|
|
189
|
+
eventBusConfig={{
|
|
190
|
+
debug: false, // enable debug logging for the event bus
|
|
191
|
+
connectToServerBus: false, // connect to the Vite plugin server event bus
|
|
192
|
+
port: 3000, // port for server event bus connection
|
|
193
|
+
}}
|
|
194
|
+
/>
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
The server event bus requires the `@tanstack/devtools-vite` plugin to be running.
|
|
198
|
+
|
|
199
|
+
### Plugin Registration with defaultOpen
|
|
200
|
+
|
|
201
|
+
Each plugin entry can include a `defaultOpen` flag to control whether that plugin tab is active when devtools first opens:
|
|
202
|
+
|
|
203
|
+
```tsx
|
|
204
|
+
import { TanStackDevtools } from '@tanstack/react-devtools'
|
|
205
|
+
import { FormDevtools } from '@tanstack/react-form'
|
|
206
|
+
;<TanStackDevtools
|
|
207
|
+
config={{ hideUntilHover: true }}
|
|
208
|
+
eventBusConfig={{ debug: true }}
|
|
209
|
+
plugins={[
|
|
210
|
+
{
|
|
211
|
+
name: 'TanStack Form',
|
|
212
|
+
render: <FormDevtools />,
|
|
213
|
+
defaultOpen: true,
|
|
214
|
+
},
|
|
215
|
+
]}
|
|
216
|
+
/>
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
### Conditional Devtools with URL Flag
|
|
220
|
+
|
|
221
|
+
Use `requireUrlFlag` to hide devtools unless a specific URL parameter is present. This is useful for staging environments or team-internal debugging:
|
|
222
|
+
|
|
223
|
+
```tsx
|
|
224
|
+
<TanStackDevtools
|
|
225
|
+
config={{
|
|
226
|
+
requireUrlFlag: true,
|
|
227
|
+
urlFlag: 'tanstack-devtools', // visit ?tanstack-devtools to enable
|
|
228
|
+
}}
|
|
229
|
+
/>
|
|
230
|
+
```
|
|
231
|
+
|
|
232
|
+
## Common Mistakes
|
|
233
|
+
|
|
234
|
+
### CRITICAL: Vue plugin uses `render` instead of `component`
|
|
235
|
+
|
|
236
|
+
The Vue adapter uses `component` (a Vue component reference) and optional `props`, not JSX `render`. Using `render` produces a silent failure -- the plugin tab appears but renders nothing.
|
|
237
|
+
|
|
238
|
+
Wrong:
|
|
239
|
+
|
|
240
|
+
```vue
|
|
241
|
+
<!-- This silently fails - render is ignored in Vue adapter -->
|
|
242
|
+
<script setup lang="ts">
|
|
243
|
+
const plugins = [{ name: 'My Plugin', render: MyComponent }]
|
|
244
|
+
</script>
|
|
245
|
+
```
|
|
246
|
+
|
|
247
|
+
Correct:
|
|
248
|
+
|
|
249
|
+
```vue
|
|
250
|
+
<script setup lang="ts">
|
|
251
|
+
import type { TanStackDevtoolsVuePlugin } from '@tanstack/vue-devtools'
|
|
252
|
+
|
|
253
|
+
const plugins: TanStackDevtoolsVuePlugin[] = [
|
|
254
|
+
{ name: 'My Plugin', component: MyComponent },
|
|
255
|
+
]
|
|
256
|
+
</script>
|
|
257
|
+
```
|
|
258
|
+
|
|
259
|
+
The `TanStackDevtoolsVuePlugin` type enforces this at compile time. Always import and use it.
|
|
260
|
+
|
|
261
|
+
### HIGH: Vite plugin not placed first in plugins array
|
|
262
|
+
|
|
263
|
+
The `@tanstack/devtools-vite` plugin performs source injection that must run before framework plugins (React, Vue, Solid, etc.) process the code.
|
|
264
|
+
|
|
265
|
+
Wrong:
|
|
266
|
+
|
|
267
|
+
```ts
|
|
268
|
+
import { devtools } from '@tanstack/devtools-vite'
|
|
269
|
+
import react from '@vitejs/plugin-react'
|
|
270
|
+
|
|
271
|
+
export default {
|
|
272
|
+
plugins: [react(), devtools()],
|
|
273
|
+
}
|
|
274
|
+
```
|
|
275
|
+
|
|
276
|
+
Correct:
|
|
277
|
+
|
|
278
|
+
```ts
|
|
279
|
+
import { devtools } from '@tanstack/devtools-vite'
|
|
280
|
+
import react from '@vitejs/plugin-react'
|
|
281
|
+
|
|
282
|
+
export default {
|
|
283
|
+
plugins: [devtools(), react()],
|
|
284
|
+
}
|
|
285
|
+
```
|
|
286
|
+
|
|
287
|
+
### HIGH: Mounting TanStackDevtools in SSR without client guard
|
|
288
|
+
|
|
289
|
+
The devtools core shell requires DOM APIs (`document`, `window`, `localStorage`). The React adapter includes `'use client'` at its entry point, so standard Next.js/Remix setups work. However, custom SSR setups or frameworks that do not respect the `'use client'` directive need explicit guards.
|
|
290
|
+
|
|
291
|
+
Wrong:
|
|
292
|
+
|
|
293
|
+
```tsx
|
|
294
|
+
// In a server-rendered component without framework 'use client' support
|
|
295
|
+
import { TanStackDevtools } from '@tanstack/react-devtools'
|
|
296
|
+
|
|
297
|
+
export default function Layout({ children }) {
|
|
298
|
+
return (
|
|
299
|
+
<>
|
|
300
|
+
{children}
|
|
301
|
+
<TanStackDevtools />
|
|
302
|
+
</>
|
|
303
|
+
)
|
|
304
|
+
}
|
|
305
|
+
```
|
|
306
|
+
|
|
307
|
+
Correct:
|
|
308
|
+
|
|
309
|
+
```tsx
|
|
310
|
+
import { TanStackDevtools } from '@tanstack/react-devtools'
|
|
311
|
+
|
|
312
|
+
export default function Layout({ children }) {
|
|
313
|
+
return (
|
|
314
|
+
<>
|
|
315
|
+
{children}
|
|
316
|
+
{typeof window !== 'undefined' && <TanStackDevtools />}
|
|
317
|
+
</>
|
|
318
|
+
)
|
|
319
|
+
}
|
|
320
|
+
```
|
|
321
|
+
|
|
322
|
+
Or use dynamic imports / lazy loading to ensure the component only loads on the client.
|
|
323
|
+
|
|
324
|
+
### MEDIUM: Installing as regular dependency for dev-only use
|
|
325
|
+
|
|
326
|
+
When using the Vite plugin for production stripping, devtools packages should be dev dependencies. Installing them as regular dependencies increases production bundle size unnecessarily.
|
|
327
|
+
|
|
328
|
+
Wrong:
|
|
329
|
+
|
|
330
|
+
```bash
|
|
331
|
+
npm install @tanstack/react-devtools
|
|
332
|
+
```
|
|
333
|
+
|
|
334
|
+
Correct:
|
|
335
|
+
|
|
336
|
+
```bash
|
|
337
|
+
npm install -D @tanstack/react-devtools
|
|
338
|
+
npm install -D @tanstack/devtools-vite
|
|
339
|
+
```
|
|
340
|
+
|
|
341
|
+
Exception: if you intentionally want devtools in production, install `@tanstack/devtools` (core) as a regular dependency. See the production skill for details.
|
|
342
|
+
|
|
343
|
+
### MEDIUM: Not keeping devtools packages at latest versions
|
|
344
|
+
|
|
345
|
+
All `@tanstack/devtools-*` packages share internal protocols (event bus messages, plugin mount lifecycle). Mixing versions can cause silent failures where plugins register but never receive events, or the shell mounts but plugins do not render.
|
|
346
|
+
|
|
347
|
+
Always update all devtools packages together:
|
|
348
|
+
|
|
349
|
+
```bash
|
|
350
|
+
npm install -D @tanstack/react-devtools@latest @tanstack/devtools-vite@latest
|
|
351
|
+
```
|
|
352
|
+
|
|
353
|
+
When building custom plugins, ensure `@tanstack/devtools-event-client` matches the version of `@tanstack/devtools` used by the shell.
|
|
354
|
+
|
|
355
|
+
## See Also
|
|
356
|
+
|
|
357
|
+
- **devtools-vite-plugin** -- Vite plugin configuration: source inspection, console piping, production stripping, server event bus setup
|
|
358
|
+
- **devtools-production** -- Production build handling: keeping devtools in prod, tree-shaking, URL flag gating
|
|
359
|
+
- **devtools-plugin-panel** -- Building custom plugin panels with the EventClient API
|