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

quick-start.md

318 lines7.1 KB

1---
2title: Quick Start
3id: quick-start
4---
5​
6TanStack Devtools is a framework-agnostic devtool for managing and debugging devtools plugins across React, Preact, Solid, Vue, Svelte, and Angular. Pick your framework below to get started.
7​
8## React
9​
10Install the devtools and the Vite plugin:
11​
12```bash
13npm install -D @tanstack/react-devtools @tanstack/devtools-vite
14```
15​
16Add the `TanStackDevtools` component to the root of your application:
17​
18```tsx
19import { StrictMode } from 'react'
20import { createRoot } from 'react-dom/client'
21import { TanStackDevtools } from '@tanstack/react-devtools'
22​
23import App from './App'
24​
25createRoot(document.getElementById('root')!).render(
26 <StrictMode>
27 <App />
28 <TanStackDevtools />
29 </StrictMode>,
31```
32​
33To add plugins, pass them via the `plugins` prop. Each plugin needs a `name` and a `render` element:
34​
35```tsx
36import { StrictMode } from 'react'
37import { createRoot } from 'react-dom/client'
38import { TanStackDevtools } from '@tanstack/react-devtools'
39import { ReactQueryDevtoolsPanel } from '@tanstack/react-query-devtools'
40import { TanStackRouterDevtoolsPanel } from '@tanstack/react-router-devtools'
41​
42import App from './App'
43​
44createRoot(document.getElementById('root')!).render(
45 <StrictMode>
46 <App />
47 <TanStackDevtools
48 plugins={[
49 {
50 name: 'TanStack Query',
51 render: <ReactQueryDevtoolsPanel />,
52 },
53 {
54 name: 'TanStack Router',
55 render: <TanStackRouterDevtoolsPanel />,
56 },
57 ]}
58 />
59 </StrictMode>,
61```
62​
63## Preact
64​
65Install the devtools and the Vite plugin:
66​
67```bash
68npm install -D @tanstack/preact-devtools @tanstack/devtools-vite
69```
70​
71Add the `TanStackDevtools` component using Preact's `render()` function:
72​
73```tsx
74import { render } from 'preact'
75import { TanStackDevtools } from '@tanstack/preact-devtools'
76​
77import App from './App'
78​
79render(
80 <>
81 <App />
82 <TanStackDevtools />
83 </>,
84 document.getElementById('root')!,
86```
87​
88To add plugins, pass them via the `plugins` prop:
89​
90```tsx
91import { render } from 'preact'
92import { TanStackDevtools } from '@tanstack/preact-devtools'
93​
94import App from './App'
95​
96render(
97 <>
98 <App />
99 <TanStackDevtools
100 plugins={[
101 {
102 name: 'Your Plugin',
103 render: <YourPluginComponent />,
104 },
105 ]}
106 />
107 </>,
108 document.getElementById('root')!,
110```
111​
112## Solid
113​
114Install the devtools and the Vite plugin:
115​
116```bash
117npm install -D @tanstack/solid-devtools @tanstack/devtools-vite
118```
119​
120Add the `TanStackDevtools` component using Solid's `render(() => ...)` pattern:
121​
122```tsx
123import { render } from 'solid-js/web'
124import { TanStackDevtools } from '@tanstack/solid-devtools'
125​
126import App from './App'
127​
128render(() => (
129 <>
130 <App />
131 <TanStackDevtools />
132 </>
133), document.getElementById('root')!)
134```
135​
136To add plugins, pass them via the `plugins` prop:
137​
138```tsx
139import { render } from 'solid-js/web'
140import { TanStackDevtools } from '@tanstack/solid-devtools'
141import { SolidQueryDevtoolsPanel } from '@tanstack/solid-query-devtools'
142import { TanStackRouterDevtoolsPanel } from '@tanstack/solid-router-devtools'
143​
144import App from './App'
145​
146render(() => (
147 <>
148 <App />
149 <TanStackDevtools
150 plugins={[
151 {
152 name: 'TanStack Query',
153 render: <SolidQueryDevtoolsPanel />,
154 },
155 {
156 name: 'TanStack Router',
157 render: <TanStackRouterDevtoolsPanel />,
158 },
159 ]}
160 />
161 </>
162), document.getElementById('root')!)
163```
164​
165## Vue
166​
167Install the Vue devtools adapter:
168​
169```bash
170npm install -D @tanstack/vue-devtools
171```
172​
173> The Vite plugin (`@tanstack/devtools-vite`) is optional for Vue but recommended if you want features like enhanced console logs and go-to-source.
174​
175Add the `TanStackDevtools` component in your root template:
176​
177```vue
178<script setup lang="ts">
179import { TanStackDevtools } from '@tanstack/vue-devtools'
180</script>
181​
182<template>
183 <App />
184 <TanStackDevtools />
185</template>
186```
187​
188To add plugins, define them as an array and pass them via the `:plugins` binding. Vue uses `component` instead of `render` in plugin definitions:
189​
190```vue
191<script setup lang="ts">
192import { TanStackDevtools } from '@tanstack/vue-devtools'
193import type { TanStackDevtoolsVuePlugin } from '@tanstack/vue-devtools'
194import { VueQueryDevtoolsPanel } from '@tanstack/vue-query-devtools'
195​
196const plugins: TanStackDevtoolsVuePlugin[] = [
197 { name: 'Vue Query', component: VueQueryDevtoolsPanel },
199</script>
200​
201<template>
202 <App />
203 <TanStackDevtools :plugins="plugins" />
204</template>
205```
206​
207## Svelte
208​
209Install the devtools:
210​
211```bash
212npm install @tanstack/svelte-devtools
213```
214​
215Add the `TanStackDevtools` component to the root of your application:
216​
217```svelte
218<script lang="ts">
219 import { TanStackDevtools } from '@tanstack/svelte-devtools'
220</script>
221​
222<main>
223 <!-- Your app content -->
224</main>
225<TanStackDevtools />
226```
227​
228To add plugins, define them as an array and pass them via the `plugins` prop. Svelte uses `component` instead of `render` in plugin definitions:
229​
230```svelte
231<script lang="ts">
232 import { TanStackDevtools } from '@tanstack/svelte-devtools'
233 import type { TanStackDevtoolsSveltePlugin } from '@tanstack/svelte-devtools'
234 import { SvelteQueryDevtoolsPanel } from '@tanstack/svelte-query-devtools'
235​
236 const plugins: TanStackDevtoolsSveltePlugin[] = [
237 { name: 'Svelte Query', component: SvelteQueryDevtoolsPanel },
238 ]
239</script>
240​
241<main>
242 <!-- Your app content -->
243</main>
244<TanStackDevtools {plugins} />
245```
246​
247## Angular
248​
249Install the devtools:
250​
251```bash
252npm install @tanstack/angular-devtools
253```
254​
255Add the `TanStackDevtoolsComponent` to the root of your application:
256​
257```typescript
258import { Component } from '@angular/core'
259import { TanStackDevtoolsComponent } from '@tanstack/angular-devtools'
260​
261@Component({
262 selector: 'app-root',
263 standalone: true,
264 imports: [TanStackDevtoolsComponent],
265 template: `
266 <app-content />
267 <tanstack-devtools />
268 `,
269})
270export class AppComponent {}
271```
272​
273To add plugins, define them as an array and pass them via the `[plugins]` input. Angular uses `component` instead of `render` in plugin definitions:
274​
275```typescript
276import { Component } from '@angular/core'
277import { TanStackDevtoolsComponent } from '@tanstack/angular-devtools'
278import type { TanStackDevtoolsAngularPlugin } from '@tanstack/angular-devtools'
279import { AngularQueryDevtoolsPanel } from '@tanstack/angular-query-devtools'
280​
281@Component({
282 selector: 'app-root',
283 standalone: true,
284 imports: [TanStackDevtoolsComponent],
285 template: `
286 <app-content />
287 <tanstack-devtools [plugins]="plugins" />
288 `,
289})
290export class AppComponent {
291 plugins: Array<TanStackDevtoolsAngularPlugin> = [
292 { name: 'Angular Query', component: AngularQueryDevtoolsPanel },
293 ]
295```
296​
297## Vite Plugin
298​
299All frameworks benefit from the optional Vite plugin, which provides enhanced console logs, go-to-source, and a server event bus. Install it as a dev dependency:
300​
301```bash
302npm install -D @tanstack/devtools-vite
303```
304​
305Add it as the **first** plugin in your Vite config:
306​
307```ts
308import { devtools } from '@tanstack/devtools-vite'
309​
310export default {
311 plugins: [
312 devtools(),
313 // ... rest of your plugins here
314 ],
316```
317​
318For the full list of Vite plugin options, see the [Vite Plugin](./vite-plugin) documentation.