8.3 KiB
| title | id |
|---|---|
| Devtools | devtools |
TanStack Table provides framework-specific devtools adapters that plug into the TanStack Devtools multi-panel UI.
The table devtools let you inspect registered table instances, switch between multiple tables, and inspect features, state, options, rows, and columns in real time.
Note
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
/productionentrypoints.
Installation
Install the TanStack Devtools host package and the Table adapter for your framework.
React
npm install @tanstack/react-devtools @tanstack/react-table-devtools
Preact
npm install @tanstack/preact-devtools @tanstack/preact-table-devtools
Octane
There is not currently a dedicated Octane Table Devtools adapter.
Vue
npm install @tanstack/vue-devtools @tanstack/vue-table-devtools
Solid
npm install @tanstack/solid-devtools @tanstack/solid-table-devtools
Angular
npm install @tanstack/angular-devtools @tanstack/angular-table-devtools
Octane, Lit, Svelte, Alpine, and vanilla do not currently ship dedicated table devtools adapters.
The Required key Table Option
The devtools identify each table by the key table option. Registration requires it. If you register a table without a key, the devtools log an error (Missing table key. Add a 'key' option to your table to use devtools.) and skip the table entirely.
const table = useTable({
key: 'users-table', // needed for devtools, omit if you don't want to use the devtools
features,
columns,
data,
})
The key is also the label shown in the devtools panel selector, so give each table a unique, descriptive key.
Setup Pattern
The recommended setup has three parts:
- Give each table a unique
keyoption - Mount
TanStackDevtoolsat the app root withtableDevtoolsPlugin() - Register each table with
useTanStackTableDevtools(table)(orinjectTanStackTableDevtoolsin Angular) immediately after creating it
If you register multiple tables, the Table panel shows a selector so you can switch between them.
Setup
React
import React from 'react'
import ReactDOM from 'react-dom/client'
import { useTable } from '@tanstack/react-table'
import { TanStackDevtools } from '@tanstack/react-devtools'
import {
tableDevtoolsPlugin,
useTanStackTableDevtools,
} from '@tanstack/react-table-devtools'
function App() {
const table = useTable({
key: 'users-table', // needed for devtools
// ...
})
useTanStackTableDevtools(table)
return <AppContent table={table} />
}
ReactDOM.createRoot(document.getElementById('root')!).render(
<React.StrictMode>
<App />
<TanStackDevtools plugins={[tableDevtoolsPlugin()]} />
</React.StrictMode>,
)
See the React row-selection example.
Preact
import { render } from 'preact'
import { useTable } from '@tanstack/preact-table'
import { TanStackDevtools } from '@tanstack/preact-devtools'
import {
tableDevtoolsPlugin,
useTanStackTableDevtools,
} from '@tanstack/preact-table-devtools'
function App() {
const table = useTable({
key: 'users-table', // needed for devtools
// ...
})
useTanStackTableDevtools(table)
return <AppContent table={table} />
}
render(
<>
<App />
<TanStackDevtools plugins={[tableDevtoolsPlugin()]} />
</>,
document.getElementById('root')!,
)
Octane
Octane tables expose the same table.state, slice atoms, table.store, and table.Subscribe inspection surfaces, but there is not currently an Octane Table Devtools plugin to register.
See the Preact row-selection example.
Vue
// main.ts
import { createApp, defineComponent, h } from 'vue'
import { TanStackDevtools } from '@tanstack/vue-devtools'
import { tableDevtoolsPlugin } from '@tanstack/vue-table-devtools'
import App from './App.vue'
const Root = defineComponent({
setup() {
return () => [
h(App),
h(TanStackDevtools, {
plugins: [tableDevtoolsPlugin({})],
}),
]
},
})
createApp(Root).mount('#app')
<script setup lang="ts">
import { useTable } from '@tanstack/vue-table'
import { useTanStackTableDevtools } from '@tanstack/vue-table-devtools'
const table = useTable({
key: 'users-table', // needed for devtools
// ...
})
useTanStackTableDevtools(table)
</script>
See the Vue row-selection example.
Solid
import { render } from 'solid-js/web'
import { createTable } from '@tanstack/solid-table'
import { TanStackDevtools } from '@tanstack/solid-devtools'
import {
tableDevtoolsPlugin,
useTanStackTableDevtools,
} from '@tanstack/solid-table-devtools'
function App() {
const table = createTable({
key: 'users-table', // needed for devtools
// ...
})
useTanStackTableDevtools(table)
return <AppContent table={table} />
}
render(
() => (
<>
<App />
<TanStackDevtools plugins={[tableDevtoolsPlugin()]} />
</>
),
document.getElementById('root')!,
)
See the Solid row-selection example.
Angular
Provide the devtools host once in your application config, rendering the table panel from @tanstack/angular-table-devtools:
// app.config.ts
import { isDevMode } from '@angular/core'
import { provideTanStackDevtools } from '@tanstack/angular-devtools/provider'
import type { ApplicationConfig } from '@angular/core'
export const appConfig: ApplicationConfig = {
providers: [
isDevMode()
? provideTanStackDevtools(() => ({
plugins: [
{
name: 'TanStack Table',
render: () =>
import('@tanstack/angular-table-devtools').then((m) =>
m.TableDevtoolsPanel(),
),
},
],
}))
: [],
],
}
Then register each table with injectTanStackTableDevtools in an injection context (such as a component constructor):
import { Component } from '@angular/core'
import { injectTable } from '@tanstack/angular-table'
import { injectTanStackTableDevtools } from '@tanstack/angular-table-devtools'
@Component({
// ...
})
export class App {
constructor() {
injectTanStackTableDevtools(() => ({
table: this.table,
}))
}
readonly table = injectTable(() => ({
key: 'users-table', // needed for devtools
// ...
}))
}
See the Angular basic example or the Angular row-selection example.
Disabling Registration
Each registration function accepts an enabled option if you want to conditionally register a table:
React
useTanStackTableDevtools(table, { enabled: false })
Preact
useTanStackTableDevtools(table, { enabled: false })
Octane
No adapter toggle is required because Octane does not currently ship a Table Devtools adapter.
Vue
useTanStackTableDevtools(table, { enabled: false })
Solid
useTanStackTableDevtools(table, { enabled: false })
Angular
injectTanStackTableDevtools(() => ({
table: this.table,
enabled: () => false,
}))
Production Builds
If you need the live devtools in production, import from the /production entrypoint for your framework package:
React
import {
tableDevtoolsPlugin,
useTanStackTableDevtools,
} from '@tanstack/react-table-devtools/production'
Preact
import {
tableDevtoolsPlugin,
useTanStackTableDevtools,
} from '@tanstack/preact-table-devtools/production'
Octane
There is no production Devtools entry point for Octane Table at this time.
Vue
import {
tableDevtoolsPlugin,
useTanStackTableDevtools,
} from '@tanstack/vue-table-devtools/production'
Solid
import {
tableDevtoolsPlugin,
useTanStackTableDevtools,
} from '@tanstack/solid-table-devtools/production'
Angular
import { injectTanStackTableDevtools } from '@tanstack/angular-table-devtools/production'