Skip to content
Skillpedia
Websites & UI (frontend)29k · #9833

table-state

What it does

This skill explains how to keep table settings, like the current page, in Svelte runes and read them in the template. It is for Svelte developers whose table and page must stay in step.

When to use it

  • ✓When a Svelte template must show the current page or another table setting.
  • ✓When you need to connect a table's pagination to a rune.
  • ✓When a value read outside the template or derived code does not update after a change.

Skill link

https://github.com/TanStack/table/blob/main/packages/svelte-table/skills/table-state/SKILL.md

Copy it and paste it into your AI (Claude, ChatGPT or Cursor), asking it to follow the instructions.

How to use

The easiest way: copy the message and paste it into your AI. It reads the skill and follows the instructions.

Ready-to-paste message

Use this skill to help me: https://github.com/TanStack/table/blob/main/packages/svelte-table/skills/table-state/SKILL.md Read the SKILL.md file at that link and follow its instructions for my task.
Want your AI to find skills like this on its own?Install the free Skillpedia MCP: one line, and it searches 15,000+ skills before each task.Install in 1 minute →

Example of what to ask your AI

“How do I make my Svelte table's page number update on screen when I click next?”

5 new skills a week. 1 minute to read.

How it works

It shows how to keep the pagination setting in a rune, pass it to the table with getters and an update callback, and read the state in templates or derived values.

Technical content (original SKILL.md)

Original text by the author, straight from GitHub.

Svelte table state

Before starting, run intent load @tanstack/table-core#table-state for shared ownership, initialization, updates, and resets.

Read reactive state

In Svelte 5, table.atoms.<slice>.get(), table.store.get(), and Table API reads track dependencies inside templates, $derived, $derived.by, or $effect. Outside those contexts they return snapshots. Prefer a slice read; a whole-store read reruns for every registered state change.

createTable and createAppTable take only options. There is no selected table.state, subscribeTable, or SubscribeSource. Use native $derived projections.

Control a slice

Keep features and columns stable. Expose changing data and controlled runes through getters, and resolve both forms of Updater:

<script lang="ts">
  import {
    createTable,
    rowPaginationFeature,
    tableFeatures,
    type PaginationState,
  } from '@tanstack/svelte-table'

  const features = tableFeatures({ rowPaginationFeature })
  const columns = [{ accessorKey: 'name' }]
  let data = $state([{ name: 'Ada' }])
  let pagination = $state<PaginationState>({ pageIndex: 0, pageSize: 20 })
  const table = createTable({
    features,
    columns,
    get data() {
      return data
    },
    state: {
      get pagination() {
        return pagination
      },
    },
    onPaginationChange: (next) => {
      pagination = typeof next === 'function' ? next(pagination) : next
    },
  })
  const pageSize = $derived(table.atoms.pagination.get().pageSize)
</script>

<button onclick={() => table.setPageSize(50)}>{pageSize} rows per page</button>

createTableState provides an updater-compatible getter/setter pair when repeating this wiring. For raw external atoms consumed outside table UI, use useSelector from @tanstack/svelte-store; table UI uses the rune-aware table.atoms wrappers.

For createTableState, external atoms, broad invalidation, or a page index overwritten by automatic reset, read reactivity details. For changes to pagination processing or reset policy, run intent load @tanstack/table-core#table-features and read its pagination reference.

API discovery

Inspect node_modules/@tanstack/svelte-table/dist/createTable.svelte.d.ts, createTableState.svelte.d.ts, and createTableHook.svelte.d.ts for the installed contracts.

FAQ

Why does a value read in a plain function not refresh?

Svelte tracks reads only inside templates, derived values or effects, so other reads are snapshots.

Is there a selected state object in Svelte?

No. The skill says createTable takes only options, so projections should use native derived values.

Should I read the whole store or just one slice?

The skill recommends reading a single slice, since reading the whole store reruns for every registered state change.

Details

Original description by the author

Read and control Table v9 state in svelte. Use for tracked reads, subscriptions, controlled slices, and framework-specific reactive boundaries.

repo: TanStack/table

Popularity

GitHub stars
29k
Ranking position
#9833
License
MIT
Updated
10/21/2026

Is this skill useful?

0

Sign in to vote.

Comments

  • …

More skills from this repository

Similar skills