Preact Table setup and integration
Before starting, run intent load @tanstack/table-core#core for the shared headless model and stable-input rules.
Setup
import { useState } from 'preact/hooks'
import {
createColumnHelper,
tableFeatures,
useTable,
} from '@tanstack/preact-table'
type Person = { name: string }
const features = tableFeatures({})
const helper = createColumnHelper<typeof features, Person>()
const columns = helper.columns([helper.accessor('name', { header: 'Name' })])
export function PeopleTable() {
const [data] = useState<Person[]>([{ name: 'Ada' }])
const table = useTable({ features, columns, data })
return (
<table>
<thead>
{table.getHeaderGroups().map((group) => (
<tr key={group.id}>
{group.headers.map((header) => (
<th key={header.id}>
<table.FlexRender header={header} />
</th>
))}
</tr>
))}
</thead>
<tbody>
{table.getRowModel().rows.map((row) => (
<tr key={row.id}>
{row.getAllCells().map((cell) => (
<td key={cell.id}>
<table.FlexRender cell={cell} />
</td>
))}
</tr>
))}
</tbody>
</table>
)
}
Essential constraints
Use native @tanstack/preact-table and preact/hooks. V8 React-through-compat setup and useReactTable are not the native v9 API. Keep features, columns, and fallback arrays stable across renders.
Table owns models and state. The application owns markup, CSS, interactions, and accessibility. Core-only tables use row.getAllCells(); visibility-aware methods need columnVisibilityFeature. Optional state and APIs require their features. Put row-model slots after their prerequisite features in tableFeatures().
Load by task
- For repeated features, defaults, typed contexts, or component registries, read reusable app hooks.
- For Query-backed data, server pages, sorting, filtering, or request keys, read TanStack Query integration.
- For virtual rows, columns, dynamic measurement, or infinite scrolling, read TanStack Virtual integration.
- For controlled state, tracked reads, or render subscriptions, read table state.
- For feature registration, missing feature APIs, or processing ownership, run
intent load @tanstack/table-core#table-features and read only references needed by the task.
- For v8 code, read the migration checklist.
API discovery
Inspect node_modules/@tanstack/preact-table/dist/index.d.ts, then the exported adapter declarations for the installed version. Inspect optional core APIs under node_modules/@tanstack/table-core/dist/features/.
1---2name: getting-started-83description: Create and render Table v9 with the preact adapter. Route reusable createTableHook components, Query and Virtual integration, and framework setup; use table-state for reactive ownership.4metadata:5 source: https://skillmd.com/skills/tanstack/getting-started-86 type: framework7 library: '@tanstack/preact-table'8 library_version: '9.3.1'9 framework: preact10requires:11 - '@tanstack/table-core#core'12sources:13 - TanStack/table:docs/framework/preact/guide/migrating.md14 - TanStack/table:examples/preact/basic-use-table15 - TanStack/table:packages/preact-table/src/index.ts16 - TanStack/table:docs/framework/preact/guide/composable-tables.md17 - TanStack/table:docs/framework/preact/guide/table-context.md18 - TanStack/table:examples/preact/composable-tables19 - TanStack/table:packages/preact-table/src/createTableHook.tsx20 - TanStack/table:packages/preact-table/src/createTableHookContexts.tsx21 - TanStack/table:examples/preact/with-tanstack-query22 - TanStack/table:docs/framework/preact/guide/pagination.md23 - TanStack/table:docs/framework/preact/guide/virtualization.md24---2526# Preact Table setup and integration2728Before starting, run `intent load @tanstack/table-core#core` for the shared headless model and stable-input rules.2930## Setup3132```tsx33import { useState } from 'preact/hooks'34import {35 createColumnHelper,36 tableFeatures,37 useTable,38} from '@tanstack/preact-table'3940type Person = { name: string }41const features = tableFeatures({})42const helper = createColumnHelper<typeof features, Person>()43const columns = helper.columns([helper.accessor('name', { header: 'Name' })])4445export function PeopleTable() {46 const [data] = useState<Person[]>([{ name: 'Ada' }])47 const table = useTable({ features, columns, data })48 return (49 <table>50 <thead>51 {table.getHeaderGroups().map((group) => (52 <tr key={group.id}>53 {group.headers.map((header) => (54 <th key={header.id}>55 <table.FlexRender header={header} />56 </th>57 ))}58 </tr>59 ))}60 </thead>61 <tbody>62 {table.getRowModel().rows.map((row) => (63 <tr key={row.id}>64 {row.getAllCells().map((cell) => (65 <td key={cell.id}>66 <table.FlexRender cell={cell} />67 </td>68 ))}69 </tr>70 ))}71 </tbody>72 </table>73 )74}75```7677## Essential constraints7879Use native `@tanstack/preact-table` and `preact/hooks`. V8 React-through-compat setup and `useReactTable` are not the native v9 API. Keep features, columns, and fallback arrays stable across renders.8081Table owns models and state. The application owns markup, CSS, interactions, and accessibility. Core-only tables use `row.getAllCells()`; visibility-aware methods need `columnVisibilityFeature`. Optional state and APIs require their features. Put row-model slots after their prerequisite features in `tableFeatures()`.8283## Load by task8485- For repeated features, defaults, typed contexts, or component registries, read [reusable app hooks](references/create-table-hook.md).86- For Query-backed data, server pages, sorting, filtering, or request keys, read [TanStack Query integration](references/with-tanstack-query.md).87- For virtual rows, columns, dynamic measurement, or infinite scrolling, read [TanStack Virtual integration](references/with-tanstack-virtual.md).88- For controlled state, tracked reads, or render subscriptions, read [table state](../table-state/SKILL.md).89- For feature registration, missing feature APIs, or processing ownership, run `intent load @tanstack/table-core#table-features` and read only references needed by the task.90- For v8 code, read the [migration checklist](../migrate-v8-to-v9/SKILL.md).9192## API discovery9394Inspect `node_modules/@tanstack/preact-table/dist/index.d.ts`, then the exported adapter declarations for the installed version. Inspect optional core APIs under `node_modules/@tanstack/table-core/dist/features/`.