Skip to content

Commit e9977ba

Browse files
committed
feat: vue and preact devtools
1 parent 50ed492 commit e9977ba

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+1392
-289
lines changed

docs/config.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@
2121
"label": "Installation",
2222
"to": "installation"
2323
},
24+
{
25+
"label": "Devtools",
26+
"to": "devtools"
27+
},
2428
{
2529
"label": "FAQ",
2630
"to": "faq"

docs/devtools.md

Lines changed: 207 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,207 @@
1+
---
2+
title: Devtools
3+
id: devtools
4+
---
5+
6+
TanStack Table provides framework-specific devtools adapters that plug into the [TanStack Devtools](https://tanstack.com/devtools) multi-panel UI.
7+
8+
The table devtools let you inspect registered table instances, switch between multiple tables, and inspect features, state, options, rows, and columns in real time.
9+
10+
> [!NOTE]
11+
> By default, the framework adapters only include the live devtools in development mode. In production builds they export no-op implementations unless you opt into the `/production` entrypoints.
12+
13+
## Installation
14+
15+
Install the TanStack Devtools host package and the Table adapter for your framework:
16+
17+
### React
18+
19+
```sh
20+
npm install @tanstack/react-devtools @tanstack/react-table-devtools
21+
```
22+
23+
### Preact
24+
25+
```sh
26+
npm install @tanstack/preact-devtools @tanstack/preact-table-devtools
27+
```
28+
29+
### Solid
30+
31+
```sh
32+
npm install @tanstack/solid-devtools @tanstack/solid-table-devtools
33+
```
34+
35+
### Vue
36+
37+
```sh
38+
npm install @tanstack/vue-devtools @tanstack/vue-table-devtools
39+
```
40+
41+
Angular, Lit, Svelte, and vanilla do not currently ship dedicated table devtools adapters.
42+
43+
## Setup Pattern
44+
45+
The recommended setup has two parts:
46+
47+
1. Mount `TanStackDevtools` at the app root with `tableDevtoolsPlugin()`
48+
2. Call `useTanStackTableDevtools(table, name?)` immediately after creating each table
49+
50+
If you register multiple tables, the Table panel shows a selector so you can switch between them.
51+
52+
## React Setup
53+
54+
```tsx
55+
import React from 'react'
56+
import ReactDOM from 'react-dom/client'
57+
import { useTable } from '@tanstack/react-table'
58+
import { TanStackDevtools } from '@tanstack/react-devtools'
59+
import {
60+
tableDevtoolsPlugin,
61+
useTanStackTableDevtools,
62+
} from '@tanstack/react-table-devtools'
63+
64+
function App() {
65+
const table = useTable({
66+
// ...
67+
})
68+
69+
useTanStackTableDevtools(table, 'Users Table')
70+
71+
return <AppContent table={table} />
72+
}
73+
74+
ReactDOM.createRoot(document.getElementById('root')!).render(
75+
<React.StrictMode>
76+
<App />
77+
<TanStackDevtools plugins={[tableDevtoolsPlugin()]} />
78+
</React.StrictMode>,
79+
)
80+
```
81+
82+
See the [React row-selection example](./framework/react/examples/row-selection).
83+
84+
## Preact Setup
85+
86+
```tsx
87+
import { render } from 'preact'
88+
import { useTable } from '@tanstack/preact-table'
89+
import { TanStackDevtools } from '@tanstack/preact-devtools'
90+
import {
91+
tableDevtoolsPlugin,
92+
useTanStackTableDevtools,
93+
} from '@tanstack/preact-table-devtools'
94+
95+
function App() {
96+
const table = useTable({
97+
// ...
98+
})
99+
100+
useTanStackTableDevtools(table, 'Users Table')
101+
102+
return <AppContent table={table} />
103+
}
104+
105+
render(
106+
<>
107+
<App />
108+
<TanStackDevtools plugins={[tableDevtoolsPlugin()]} />
109+
</>,
110+
document.getElementById('root')!,
111+
)
112+
```
113+
114+
See the [Preact sorting example](./framework/preact/examples/sorting).
115+
116+
## Solid Setup
117+
118+
```tsx
119+
import { render } from 'solid-js/web'
120+
import { createTable } from '@tanstack/solid-table'
121+
import { TanStackDevtools } from '@tanstack/solid-devtools'
122+
import {
123+
tableDevtoolsPlugin,
124+
useTanStackTableDevtools,
125+
} from '@tanstack/solid-table-devtools'
126+
127+
function App() {
128+
const table = createTable({
129+
// ...
130+
})
131+
132+
useTanStackTableDevtools(table, 'Users Table')
133+
134+
return <AppContent table={table} />
135+
}
136+
137+
render(
138+
() => (
139+
<>
140+
<App />
141+
<TanStackDevtools plugins={[tableDevtoolsPlugin()]} />
142+
</>
143+
),
144+
document.getElementById('root')!,
145+
)
146+
```
147+
148+
See the [Solid row-selection example](./framework/solid/examples/row-selection).
149+
150+
## Vue Setup
151+
152+
```ts
153+
// main.ts
154+
import { createApp, defineComponent, h } from 'vue'
155+
import { TanStackDevtools } from '@tanstack/vue-devtools'
156+
import { tableDevtoolsPlugin } from '@tanstack/vue-table-devtools'
157+
import App from './App.vue'
158+
159+
const Root = defineComponent({
160+
setup() {
161+
return () => [
162+
h(App),
163+
h(TanStackDevtools, {
164+
plugins: [tableDevtoolsPlugin()],
165+
}),
166+
]
167+
},
168+
})
169+
170+
createApp(Root).mount('#app')
171+
```
172+
173+
```vue
174+
<script setup lang="ts">
175+
import { useTable } from '@tanstack/vue-table'
176+
import { useTanStackTableDevtools } from '@tanstack/vue-table-devtools'
177+
178+
const table = useTable({
179+
// ...
180+
})
181+
182+
useTanStackTableDevtools(table, 'Users Table')
183+
</script>
184+
```
185+
186+
See the [Vue row-selection example](./framework/vue/examples/row-selection).
187+
188+
## Naming Tables
189+
190+
The optional second argument lets you label a table in the devtools selector:
191+
192+
```ts
193+
useTanStackTableDevtools(table, 'Orders Table')
194+
```
195+
196+
If you omit the name, the devtools assign fallback names such as `Table 1` and `Table 2`.
197+
198+
## Production Builds
199+
200+
If you need the live devtools in production, import from the `/production` entrypoint for your framework package:
201+
202+
```tsx
203+
import { tableDevtoolsPlugin } from '@tanstack/react-table-devtools/production'
204+
import { useTanStackTableDevtools } from '@tanstack/react-table-devtools/production'
205+
```
206+
207+
Equivalent `/production` entrypoints are available for the Preact, Solid, and Vue adapters as well.

examples/preact/sorting/package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
},
1818
"devDependencies": {
1919
"@preact/preset-vite": "^2.10.5",
20+
"@tanstack/preact-devtools": "^0.10.0",
21+
"@tanstack/preact-table-devtools": "workspace:*",
2022
"typescript": "6.0.2",
2123
"vite": "^8.0.7"
2224
}

0 commit comments

Comments
 (0)