Svelte Table setup and integration
Before starting, run intent load @tanstack/table-core#core for the shared headless model and stable-input rules.
Setup
Keep features and columns outside reactive work; expose changing rune values through getters.
<script lang="ts">
import {
createTable,
FlexRender,
tableFeatures,
} from '@tanstack/svelte-table'
type Person = { firstName: string; age: number }
const features = tableFeatures({})
const columns = [
{ accessorKey: 'firstName', header: 'First name' },
{ accessorKey: 'age', header: 'Age' },
]
let data = $state<Person[]>([{ firstName: 'Ada', age: 36 }])
const table = createTable({
features,
columns,
get data() {
return data
},
})
</script>
<table>
<thead>
{#each table.getHeaderGroups() as group (group.id)}
<tr
>{#each group.headers as header (header.id)}<th
>{#if !header.isPlaceholder}<FlexRender {header} />{/if}</th
>{/each}</tr
>
{/each}
</thead>
<tbody>
{#each table.getRowModel().rows as row (row.id)}
<tr
>{#each row.getAllCells() as cell (cell.id)}<td
><FlexRender {cell} /></td
>{/each}</tr
>
{/each}
</tbody>
</table>
Essential constraints
V9 requires Svelte 5 and createTable. Expose changing runes through getters; data captured once cannot follow reassignment. Keep features and columns outside reactive work and use $derived for transformed arrays.
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/svelte-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-93description: Create and render Table v9 with the svelte 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-96 type: framework7 library: '@tanstack/svelte-table'8 framework: svelte9 library_version: '9.3.2'10requires:11 - '@tanstack/table-core#core'12sources:13 - TanStack/table:docs/framework/svelte/guide/migrating.md14 - TanStack/table:examples/svelte/basic-create-table15 - TanStack/table:packages/svelte-table/src/index.ts16 - TanStack/table:docs/framework/svelte/guide/composable-tables.md17 - TanStack/table:examples/svelte/composable-tables18 - TanStack/table:packages/svelte-table/src/createTableHook.svelte.ts19 - TanStack/table:examples/svelte/with-tanstack-query20 - TanStack/table:docs/framework/svelte/guide/pagination.md21 - TanStack/table:docs/framework/svelte/guide/virtualization.md22 - TanStack/table:examples/svelte/virtualized-rows23 - TanStack/table:examples/svelte/virtualized-columns24 - TanStack/table:examples/svelte/virtualized-infinite-scrolling25---2627# Svelte Table setup and integration2829Before starting, run `intent load @tanstack/table-core#core` for the shared headless model and stable-input rules.3031## Setup3233Keep features and columns outside reactive work; expose changing rune values through getters.3435```svelte36<script lang="ts">37 import {38 createTable,39 FlexRender,40 tableFeatures,41 } from '@tanstack/svelte-table'4243 type Person = { firstName: string; age: number }44 const features = tableFeatures({})45 const columns = [46 { accessorKey: 'firstName', header: 'First name' },47 { accessorKey: 'age', header: 'Age' },48 ]49 let data = $state<Person[]>([{ firstName: 'Ada', age: 36 }])5051 const table = createTable({52 features,53 columns,54 get data() {55 return data56 },57 })58</script>5960<table>61 <thead>62 {#each table.getHeaderGroups() as group (group.id)}63 <tr64 >{#each group.headers as header (header.id)}<th65 >{#if !header.isPlaceholder}<FlexRender {header} />{/if}</th66 >{/each}</tr67 >68 {/each}69 </thead>70 <tbody>71 {#each table.getRowModel().rows as row (row.id)}72 <tr73 >{#each row.getAllCells() as cell (cell.id)}<td74 ><FlexRender {cell} /></td75 >{/each}</tr76 >77 {/each}78 </tbody>79</table>80```8182## Essential constraints8384V9 requires Svelte 5 and `createTable`. Expose changing runes through getters; `data` captured once cannot follow reassignment. Keep features and columns outside reactive work and use `$derived` for transformed arrays.8586Table 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()`.8788## Load by task8990- For repeated features, defaults, typed contexts, or component registries, read [reusable app hooks](references/create-table-hook.md).91- For Query-backed data, server pages, sorting, filtering, or request keys, read [TanStack Query integration](references/with-tanstack-query.md).92- For virtual rows, columns, dynamic measurement, or infinite scrolling, read [TanStack Virtual integration](references/with-tanstack-virtual.md).93- For controlled state, tracked reads, or render subscriptions, read [table state](../table-state/SKILL.md).94- 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.95- For v8 code, read the [migration checklist](../migrate-v8-to-v9/SKILL.md).9697## API discovery9899Inspect `node_modules/@tanstack/svelte-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/`.