@tanstack/svelte-table 9.0.0-alpha.9 → 9.0.0-beta.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (63) hide show
  1. package/README.md +127 -0
  2. package/dist/AppCell.svelte +13 -0
  3. package/dist/AppCell.svelte.d.ts +9 -0
  4. package/dist/AppHeader.svelte +13 -0
  5. package/dist/AppHeader.svelte.d.ts +9 -0
  6. package/dist/AppTable.svelte +11 -0
  7. package/dist/AppTable.svelte.d.ts +7 -0
  8. package/dist/FlexRender.svelte +103 -0
  9. package/dist/FlexRender.svelte.d.ts +51 -0
  10. package/dist/context-keys.d.ts +3 -0
  11. package/dist/context-keys.js +3 -0
  12. package/dist/createTable.svelte.d.ts +47 -0
  13. package/dist/createTable.svelte.js +78 -0
  14. package/dist/createTableHook.svelte.d.ts +235 -0
  15. package/dist/createTableHook.svelte.js +170 -0
  16. package/dist/createTableState.svelte.d.ts +17 -0
  17. package/dist/createTableState.svelte.js +27 -0
  18. package/dist/flex-render.d.ts +1 -0
  19. package/dist/flex-render.js +2 -0
  20. package/dist/index.d.ts +8 -3
  21. package/dist/index.js +6 -3
  22. package/dist/merge-objects.d.ts +24 -0
  23. package/dist/merge-objects.js +45 -0
  24. package/dist/reactivity.svelte.d.ts +9 -0
  25. package/dist/reactivity.svelte.js +89 -0
  26. package/dist/render-component.d.ts +66 -9
  27. package/dist/render-component.js +62 -4
  28. package/dist/static-functions.d.ts +1 -0
  29. package/dist/static-functions.js +1 -0
  30. package/dist/subscribe.d.ts +24 -0
  31. package/dist/subscribe.js +4 -0
  32. package/package.json +31 -11
  33. package/skills/svelte/client-to-server/SKILL.md +236 -0
  34. package/skills/svelte/compose-with-tanstack-form/SKILL.md +294 -0
  35. package/skills/svelte/compose-with-tanstack-pacer/SKILL.md +176 -0
  36. package/skills/svelte/compose-with-tanstack-query/SKILL.md +296 -0
  37. package/skills/svelte/compose-with-tanstack-store/SKILL.md +270 -0
  38. package/skills/svelte/compose-with-tanstack-virtual/SKILL.md +289 -0
  39. package/skills/svelte/getting-started/SKILL.md +338 -0
  40. package/skills/svelte/migrate-v8-to-v9/SKILL.md +264 -0
  41. package/skills/svelte/production-readiness/SKILL.md +258 -0
  42. package/skills/svelte/table-state/SKILL.md +437 -0
  43. package/src/AppCell.svelte +13 -0
  44. package/src/AppHeader.svelte +13 -0
  45. package/src/AppTable.svelte +11 -0
  46. package/src/FlexRender.svelte +103 -0
  47. package/src/context-keys.ts +3 -0
  48. package/src/createTable.svelte.ts +136 -0
  49. package/src/createTableHook.svelte.ts +636 -0
  50. package/src/createTableState.svelte.ts +30 -0
  51. package/src/flex-render.ts +3 -0
  52. package/src/index.ts +20 -3
  53. package/src/merge-objects.ts +79 -0
  54. package/src/reactivity.svelte.ts +118 -0
  55. package/src/render-component.ts +75 -9
  56. package/src/static-functions.ts +1 -0
  57. package/src/subscribe.ts +46 -0
  58. package/dist/flex-render.svelte +0 -35
  59. package/dist/flex-render.svelte.d.ts +0 -28
  60. package/dist/table.svelte.d.ts +0 -28
  61. package/dist/table.svelte.js +0 -87
  62. package/src/flex-render.svelte +0 -35
  63. package/src/table.svelte.ts +0 -117
@@ -1,20 +1,51 @@
1
- import type { Component, ComponentProps } from 'svelte';
1
+ import type { Component, ComponentProps, Snippet } from 'svelte';
2
2
  /**
3
- * A helper class to make it easy to identify Svelte components in `columnDef.cell` and `columnDef.header` properties.
3
+ * A helper class to make it easy to identify Svelte components in
4
+ * `columnDef.cell` and `columnDef.header` properties.
5
+ *
6
+ * > NOTE: This class should only be used internally by the adapter. If you're
7
+ * reading this and you don't know what this is for, you probably don't need it.
8
+ *
4
9
  * @example
5
10
  * ```svelte
6
- * {#if cell.column.columnDef.cell(cell.getContext()) instanceof RenderComponentConfig}
7
- * <svelte:component this={columnDef.cell.component} {...columnDef.cell.props} />
11
+ * {@const result = content(context as any)}
12
+ * {#if result instanceof RenderComponentConfig}
13
+ * {@const { component: Component, props } = result}
14
+ * <Component {...props} />
8
15
  * {/if}
9
16
  * ```
10
17
  * */
11
- export declare class RenderComponentConfig<TComponent extends Component<any>> {
18
+ export declare class RenderComponentConfig<TComponent extends Component> {
12
19
  component: TComponent;
13
- props: ComponentProps<TComponent>;
14
- constructor(component: TComponent, props: ComponentProps<TComponent>);
20
+ props?: (ComponentProps<TComponent> | Record<string, never>) | undefined;
21
+ constructor(component: TComponent, props?: (ComponentProps<TComponent> | Record<string, never>) | undefined);
15
22
  }
16
23
  /**
17
- * A helper function to help create cells from Svelte components through ColumnDef's `cell` and `header` properties.
24
+ * A helper class to make it easy to identify Svelte Snippets in `columnDef.cell` and `columnDef.header` properties.
25
+ *
26
+ * > NOTE: This class should only be used internally by the adapter. If you're
27
+ * reading this and you don't know what this is for, you probably don't need it.
28
+ *
29
+ * @example
30
+ * ```svelte
31
+ * {@const result = content(context as any)}
32
+ * {#if result instanceof RenderSnippetConfig}
33
+ * {@const { snippet, params } = result}
34
+ * {@render snippet(params)}
35
+ * {/if}
36
+ * ```
37
+ * */
38
+ export declare class RenderSnippetConfig<TProps> {
39
+ snippet: Snippet<[TProps]>;
40
+ params?: TProps | undefined;
41
+ constructor(snippet: Snippet<[TProps]>, params?: TProps | undefined);
42
+ }
43
+ /**
44
+ * Wraps a Svelte component so it can be returned from a column definition
45
+ * renderer such as `cell`, `header`, or `footer`.
46
+ *
47
+ * This is only to be used with Svelte Components - use `renderSnippet` for Svelte Snippets.
48
+ *
18
49
  * @param component A Svelte component
19
50
  * @param props The props to pass to `component`
20
51
  * @returns A `RenderComponentConfig` object that helps svelte-table know how to render the header/cell component.
@@ -32,4 +63,30 @@ export declare class RenderComponentConfig<TComponent extends Component<any>> {
32
63
  * ```
33
64
  * @see {@link https://tanstack.com/table/latest/docs/guide/column-defs}
34
65
  */
35
- export declare const renderComponent: <TComponent extends Component<any, {}, string>>(component: TComponent, props: ComponentProps<TComponent>) => RenderComponentConfig<TComponent>;
66
+ export declare const renderComponent: <TComponent extends Component<any>, TProps extends ComponentProps<TComponent>>(component: TComponent, props?: TProps) => RenderComponentConfig<TComponent>;
67
+ /**
68
+ * Wraps a Svelte snippet so it can be returned from a column definition
69
+ * renderer such as `cell`, `header`, or `footer`.
70
+ *
71
+ * *The snippet must only take one parameter.*
72
+ *
73
+ * This is only to be used with Snippets - use `renderComponent` for Svelte Components.
74
+ *
75
+ * @param snippet The snippet to render.
76
+ * @param params The single parameter object passed to the snippet.
77
+ * @returns A `RenderSnippetConfig` consumed by the Svelte `FlexRender` component.
78
+ * @example
79
+ * ```ts
80
+ * // +page.svelte
81
+ * const defaultColumns = [
82
+ * columnHelper.accessor('name', {
83
+ * cell: cell => renderSnippet(nameSnippet, { name: cell.row.name }),
84
+ * }),
85
+ * columnHelper.accessor('state', {
86
+ * cell: cell => renderSnippet(stateSnippet, { state: cell.row.state }),
87
+ * }),
88
+ * ]
89
+ * ```
90
+ * @see {@link https://tanstack.com/table/latest/docs/guide/column-defs}
91
+ */
92
+ export declare const renderSnippet: <TProps>(snippet: Snippet<[TProps]>, params?: TProps) => RenderSnippetConfig<TProps>;
@@ -1,9 +1,16 @@
1
1
  /**
2
- * A helper class to make it easy to identify Svelte components in `columnDef.cell` and `columnDef.header` properties.
2
+ * A helper class to make it easy to identify Svelte components in
3
+ * `columnDef.cell` and `columnDef.header` properties.
4
+ *
5
+ * > NOTE: This class should only be used internally by the adapter. If you're
6
+ * reading this and you don't know what this is for, you probably don't need it.
7
+ *
3
8
  * @example
4
9
  * ```svelte
5
- * {#if cell.column.columnDef.cell(cell.getContext()) instanceof RenderComponentConfig}
6
- * <svelte:component this={columnDef.cell.component} {...columnDef.cell.props} />
10
+ * {@const result = content(context as any)}
11
+ * {#if result instanceof RenderComponentConfig}
12
+ * {@const { component: Component, props } = result}
13
+ * <Component {...props} />
7
14
  * {/if}
8
15
  * ```
9
16
  * */
@@ -14,7 +21,32 @@ export class RenderComponentConfig {
14
21
  }
15
22
  }
16
23
  /**
17
- * A helper function to help create cells from Svelte components through ColumnDef's `cell` and `header` properties.
24
+ * A helper class to make it easy to identify Svelte Snippets in `columnDef.cell` and `columnDef.header` properties.
25
+ *
26
+ * > NOTE: This class should only be used internally by the adapter. If you're
27
+ * reading this and you don't know what this is for, you probably don't need it.
28
+ *
29
+ * @example
30
+ * ```svelte
31
+ * {@const result = content(context as any)}
32
+ * {#if result instanceof RenderSnippetConfig}
33
+ * {@const { snippet, params } = result}
34
+ * {@render snippet(params)}
35
+ * {/if}
36
+ * ```
37
+ * */
38
+ export class RenderSnippetConfig {
39
+ constructor(snippet, params) {
40
+ this.snippet = snippet;
41
+ this.params = params;
42
+ }
43
+ }
44
+ /**
45
+ * Wraps a Svelte component so it can be returned from a column definition
46
+ * renderer such as `cell`, `header`, or `footer`.
47
+ *
48
+ * This is only to be used with Svelte Components - use `renderSnippet` for Svelte Snippets.
49
+ *
18
50
  * @param component A Svelte component
19
51
  * @param props The props to pass to `component`
20
52
  * @returns A `RenderComponentConfig` object that helps svelte-table know how to render the header/cell component.
@@ -33,3 +65,29 @@ export class RenderComponentConfig {
33
65
  * @see {@link https://tanstack.com/table/latest/docs/guide/column-defs}
34
66
  */
35
67
  export const renderComponent = (component, props) => new RenderComponentConfig(component, props);
68
+ /**
69
+ * Wraps a Svelte snippet so it can be returned from a column definition
70
+ * renderer such as `cell`, `header`, or `footer`.
71
+ *
72
+ * *The snippet must only take one parameter.*
73
+ *
74
+ * This is only to be used with Snippets - use `renderComponent` for Svelte Components.
75
+ *
76
+ * @param snippet The snippet to render.
77
+ * @param params The single parameter object passed to the snippet.
78
+ * @returns A `RenderSnippetConfig` consumed by the Svelte `FlexRender` component.
79
+ * @example
80
+ * ```ts
81
+ * // +page.svelte
82
+ * const defaultColumns = [
83
+ * columnHelper.accessor('name', {
84
+ * cell: cell => renderSnippet(nameSnippet, { name: cell.row.name }),
85
+ * }),
86
+ * columnHelper.accessor('state', {
87
+ * cell: cell => renderSnippet(stateSnippet, { state: cell.row.state }),
88
+ * }),
89
+ * ]
90
+ * ```
91
+ * @see {@link https://tanstack.com/table/latest/docs/guide/column-defs}
92
+ */
93
+ export const renderSnippet = (snippet, params) => new RenderSnippetConfig(snippet, params);
@@ -0,0 +1 @@
1
+ export * from '@tanstack/table-core/static-functions';
@@ -0,0 +1 @@
1
+ export * from '@tanstack/table-core/static-functions';
@@ -0,0 +1,24 @@
1
+ import { useSelector } from '@tanstack/svelte-store';
2
+ import type { Atom, ReadonlyAtom, ReadonlyStore, Store } from '@tanstack/svelte-store';
3
+ export type SubscribeSource<TValue> = Atom<TValue> | ReadonlyAtom<TValue> | Store<TValue> | ReadonlyStore<TValue>;
4
+ /**
5
+ * Creates a fine-grained Svelte subscription to a TanStack Store source.
6
+ *
7
+ * Pass a table atom or store and optionally project it with a selector. The
8
+ * returned selector store exposes `.current`, making it useful for reading
9
+ * focused table state outside the broad `createTable` selector.
10
+ *
11
+ * @example
12
+ * ```svelte
13
+ * <script lang="ts">
14
+ * const selected = subscribeTable(
15
+ * table.atoms.rowSelection,
16
+ * (rowSelection) => rowSelection[row.id],
17
+ * )
18
+ * </script>
19
+ *
20
+ * <input type="checkbox" checked={!!selected.current} />
21
+ * ```
22
+ */
23
+ export declare function subscribeTable<TSourceValue>(source: SubscribeSource<TSourceValue>): ReturnType<typeof useSelector<TSourceValue>>;
24
+ export declare function subscribeTable<TSourceValue, TSelected>(source: SubscribeSource<TSourceValue>, selector: (state: TSourceValue) => TSelected): ReturnType<typeof useSelector<TSourceValue, TSelected>>;
@@ -0,0 +1,4 @@
1
+ import { shallow, useSelector } from '@tanstack/svelte-store';
2
+ export function subscribeTable(source, selector) {
3
+ return useSelector(source, selector, { compare: shallow });
4
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tanstack/svelte-table",
3
- "version": "9.0.0-alpha.9",
3
+ "version": "9.0.0-beta.10",
4
4
  "description": "Headless UI for building powerful tables & datagrids for Svelte.",
5
5
  "author": "Tanner Linsley",
6
6
  "license": "MIT",
@@ -18,7 +18,8 @@
18
18
  "svelte",
19
19
  "table",
20
20
  "svelte-table",
21
- "datagrid"
21
+ "datagrid",
22
+ "tanstack-intent"
22
23
  ],
23
24
  "type": "module",
24
25
  "types": "dist/index.d.ts",
@@ -30,26 +31,45 @@
30
31
  "svelte": "./dist/index.js",
31
32
  "import": "./dist/index.js"
32
33
  },
34
+ "./static-functions": {
35
+ "types": "./dist/static-functions.d.ts",
36
+ "svelte": "./dist/static-functions.js",
37
+ "import": "./dist/static-functions.js"
38
+ },
39
+ "./flex-render": {
40
+ "types": "./dist/flex-render.d.ts",
41
+ "svelte": "./dist/flex-render.js",
42
+ "import": "./dist/flex-render.js"
43
+ },
33
44
  "./package.json": "./package.json"
34
45
  },
35
46
  "engines": {
36
- "node": ">=12"
47
+ "node": ">=16"
37
48
  },
38
49
  "files": [
39
50
  "dist",
40
- "src"
51
+ "src",
52
+ "skills"
41
53
  ],
42
54
  "dependencies": {
43
- "@tanstack/table-core": "9.0.0-alpha.8"
55
+ "@tanstack/svelte-store": "^0.12.0",
56
+ "@tanstack/table-core": "9.0.0-beta.10"
44
57
  },
45
58
  "devDependencies": {
46
- "@sveltejs/package": "^2.3.2",
47
- "@sveltejs/vite-plugin-svelte": "^4.0.0-next",
48
- "svelte": "^5.0.0-next",
49
- "svelte-check": "^3.8.4"
59
+ "@sveltejs/package": "^2.5.8",
60
+ "@sveltejs/vite-plugin-svelte": "^7.1.2",
61
+ "eslint-plugin-svelte": "^3.19.0",
62
+ "svelte": "^5.56.2",
63
+ "svelte-check": "^4.6.0"
50
64
  },
51
65
  "peerDependencies": {
52
- "svelte": "^5.0.0-next"
66
+ "svelte": "^5.0.0"
53
67
  },
54
- "scripts": {}
68
+ "scripts": {
69
+ "clean": "rimraf ./build && rimraf ./dist",
70
+ "test:eslint": "eslint ./src",
71
+ "test:types": "svelte-check --tsconfig ./tsconfig.json",
72
+ "test:build": "publint --strict",
73
+ "build": "svelte-package --input ./src --output ./dist"
74
+ }
55
75
  }
@@ -0,0 +1,236 @@
1
+ ---
2
+ name: svelte/client-to-server
3
+ description: >
4
+ Convert a client-side Svelte table to server-side (manual) modes. Toggle `manualPagination`,
5
+ `manualSorting`, `manualFiltering`, `manualGrouping`, `manualExpanding` for whatever the server
6
+ owns, drop the matching row-model factory slots from `tableFeatures` and any `features` you no
7
+ longer need, supply `rowCount` for the pager, then drive the request from `table.atoms.pagination`
8
+ / `table.atoms.sorting` / etc. (or external atoms you own) using rune-aware getters
9
+ (`get data()`, `get rowCount()`) so the table re-syncs in `$effect.pre`. Svelte 5+ only.
10
+ type: lifecycle
11
+ library: tanstack-table
12
+ framework: svelte
13
+ library_version: '9.0.0-alpha.48'
14
+ requires:
15
+ - state-management
16
+ - pagination
17
+ - filtering
18
+ - sorting
19
+ - svelte/table-state
20
+ sources:
21
+ - TanStack/table:examples/svelte/basic-external-atoms/
22
+ - TanStack/table:examples/svelte/basic-external-state/
23
+ - TanStack/table:examples/svelte/with-tanstack-query/
24
+ - TanStack/table:docs/framework/svelte/guide/table-state.md
25
+ ---
26
+
27
+ # Client → Server (Svelte)
28
+
29
+ You have a working client-side table. The dataset is too big to ship to the browser, or it
30
+ lives behind an API. You want sorting / filtering / pagination to run on the server while the
31
+ table still feels the same in the UI.
32
+
33
+ ## Mental model
34
+
35
+ Each "manual mode" flag tells the table: **don't run this stage of the pipeline; trust the data
36
+ you receive.** You can mix modes freely — manual pagination + client-side sorting on the
37
+ already-paged window is perfectly valid for medium datasets.
38
+
39
+ | Flag | Meaning | What you must provide |
40
+ | ------------------ | -------------------------------------------- | ----------------------------------------------------------- |
41
+ | `manualPagination` | Server owns slicing; do not paginate locally | `rowCount` (or `pageCount`) |
42
+ | `manualSorting` | Server owns ordering | Sort the server query by `sorting` state |
43
+ | `manualFiltering` | Server owns row filtering | Filter the server query by `columnFilters` / `globalFilter` |
44
+ | `manualGrouping` | Server returns already-grouped rows | Pre-shaped data |
45
+ | `manualExpanding` | Server resolves sub-rows | Server-provided sub-row tree |
46
+
47
+ When a stage is manual, you can drop its row-model factory slot from `tableFeatures`. `manualPagination: true` does not need `paginatedRowModel: createPaginatedRowModel()` in the features object.
48
+
49
+ ## Step 1 — Identify what's moving server-side
50
+
51
+ For a typical "search and paginate against a database" screen:
52
+
53
+ - Pagination → server
54
+ - Filtering (column filter inputs + a global search box) → server
55
+ - Sorting → server (usually, since a partial page can't be sorted client-side meaningfully)
56
+ - Selection / visibility / column ordering → still client
57
+
58
+ So the table keeps `rowSelectionFeature` etc., drops `columnFilteringFeature` /
59
+ `rowPaginationFeature` / `rowSortingFeature` _row models_ but keeps the _features_ so the
60
+ state slices and UI APIs still exist.
61
+
62
+ > Subtle point: keep the **feature** even if you drop the row model. The feature is what gives
63
+ > you `column.getCanSort()`, `table.setPageIndex()`, `column.setFilterValue()` — all the
64
+ > control-surface APIs. Dropping it kills the UI.
65
+
66
+ ## Step 2 — Own the relevant state with external atoms
67
+
68
+ External atoms make state portable: the data layer (a fetch / query / store) can read the
69
+ same atoms the table writes to. Use `@tanstack/svelte-store`:
70
+
71
+ ```ts
72
+ import { createAtom, useSelector } from '@tanstack/svelte-store'
73
+ import type {
74
+ ColumnFiltersState,
75
+ PaginationState,
76
+ SortingState,
77
+ } from '@tanstack/svelte-table'
78
+
79
+ const paginationAtom = createAtom<PaginationState>({
80
+ pageIndex: 0,
81
+ pageSize: 10,
82
+ })
83
+ const sortingAtom = createAtom<SortingState>([])
84
+ const filtersAtom = createAtom<ColumnFiltersState>([])
85
+
86
+ // For Svelte markup that should react to changes:
87
+ const pagination = useSelector(paginationAtom)
88
+ const sorting = useSelector(sortingAtom)
89
+ const filters = useSelector(filtersAtom)
90
+ ```
91
+
92
+ ## Step 3 — Configure the table
93
+
94
+ ```svelte
95
+ <script lang="ts">
96
+ import {
97
+ columnFilteringFeature,
98
+ createTable,
99
+ rowPaginationFeature,
100
+ rowSortingFeature,
101
+ tableFeatures,
102
+ } from '@tanstack/svelte-table'
103
+
104
+ const features = tableFeatures({
105
+ columnFilteringFeature,
106
+ rowPaginationFeature,
107
+ rowSortingFeature,
108
+ })
109
+
110
+ // No row-model factories for these — server owns them.
111
+ const table = createTable({
112
+ features,
113
+ columns,
114
+ get data() {
115
+ return query.data?.rows ?? []
116
+ },
117
+ get rowCount() {
118
+ return query.data?.rowCount
119
+ },
120
+ atoms: {
121
+ pagination: paginationAtom,
122
+ sorting: sortingAtom,
123
+ columnFilters: filtersAtom,
124
+ },
125
+ manualPagination: true,
126
+ manualSorting: true,
127
+ manualFiltering: true,
128
+ })
129
+ </script>
130
+ ```
131
+
132
+ `rowCount` is what makes `table.getPageCount()` / `table.getCanNextPage()` correct under
133
+ manual pagination. Without it the pager has no idea how many pages exist.
134
+
135
+ ## Step 4 — Drive the fetch from those atoms
136
+
137
+ Wire whatever data layer you use (TanStack Query, a raw `fetch`, SvelteKit `load`, etc.) to
138
+ read the atoms. With TanStack Query:
139
+
140
+ ```ts
141
+ import { createQuery, keepPreviousData } from '@tanstack/svelte-query'
142
+
143
+ const dataQuery = createQuery<{ rows: Array<Person>; rowCount: number }>(
144
+ () => ({
145
+ queryKey: ['people', pagination.current, sorting.current, filters.current],
146
+ queryFn: () =>
147
+ fetch('/api/people', {
148
+ method: 'POST',
149
+ body: JSON.stringify({
150
+ pageIndex: pagination.current.pageIndex,
151
+ pageSize: pagination.current.pageSize,
152
+ sorting: sorting.current,
153
+ filters: filters.current,
154
+ }),
155
+ }).then((r) => r.json()),
156
+ placeholderData: keepPreviousData,
157
+ }),
158
+ )
159
+ ```
160
+
161
+ `placeholderData: keepPreviousData` is what kills the "rows blank for one tick on every
162
+ page change" flash.
163
+
164
+ ## Step 5 — Reset behavior
165
+
166
+ When the user changes a filter, you usually want to jump back to page 0. The table does this
167
+ automatically when client-side filtering owns the data, but with manual mode the data layer
168
+ controls it. Simplest fix: explicitly reset.
169
+
170
+ ```ts
171
+ $effect(() => {
172
+ // re-runs whenever filters.current identity changes
173
+ filters.current
174
+ table.setPageIndex(0)
175
+ })
176
+ ```
177
+
178
+ Or wrap your filter `onChange` handlers to also call `table.setPageIndex(0)`.
179
+
180
+ ## Step 6 — A note on global filtering
181
+
182
+ If you also support `globalFilterFeature`, debounce the input. `column.setFilterValue` and
183
+ `table.setGlobalFilter` fire per keystroke; without debouncing you fire one request per typed
184
+ character. See the `compose-with-tanstack-pacer` skill for the pattern.
185
+
186
+ ## Hybrid example — manual pagination only
187
+
188
+ Sometimes you only paginate server-side and let the page-sized window sort/filter on the
189
+ client.
190
+
191
+ ```ts
192
+ const table = createTable({
193
+ features: tableFeatures({
194
+ columnFilteringFeature,
195
+ rowPaginationFeature,
196
+ rowSortingFeature,
197
+ filteredRowModel: createFilteredRowModel(), // client filters the page
198
+ sortedRowModel: createSortedRowModel(), // client sorts the page
199
+ filterFns,
200
+ sortFns,
201
+ }),
202
+ columns,
203
+ get data() {
204
+ return query.data?.rows ?? []
205
+ },
206
+ get rowCount() {
207
+ return query.data?.rowCount
208
+ },
209
+ atoms: { pagination: paginationAtom },
210
+ manualPagination: true,
211
+ })
212
+ ```
213
+
214
+ Only the manual flag for the stage you're moving server-side.
215
+
216
+ ## Common failure modes
217
+
218
+ - **Forgot `rowCount`.** `table.getPageCount()` returns `-1`, the pager looks broken.
219
+ - **Dropped the feature, not just the row model.** Lost `column.getCanSort()` and friends.
220
+ Keep the feature when you still need its UI APIs; only drop the row-model factory.
221
+ - **Both `state.pagination` and `atoms.pagination`.** Atoms silently win; the `on*Change`
222
+ callback never fires.
223
+ - **Re-creating atoms inside reactive blocks.** Atoms must be stable across renders. Declare
224
+ them at module / component-init scope, not inside `$derived` or `$effect`.
225
+ - **Forgetting to reset page on filter change.** Stay on page 12 of a now-2-page result set.
226
+ - **Plain `data: query.data?.rows`.** No getter, no reactivity. Use `get data()`.
227
+ - **Reimplementing pagination math.** `table.setPageIndex / nextPage / previousPage /
228
+ firstPage / lastPage / setPageSize / getCanNextPage / getCanPreviousPage / getPageCount`
229
+ already exist and respect manual mode.
230
+
231
+ ## Related skills
232
+
233
+ - `tanstack-table/svelte/compose-with-tanstack-query` — the same flow with a Query data layer.
234
+ - `tanstack-table/svelte/compose-with-tanstack-pacer` — debouncing filter inputs.
235
+ - `tanstack-table/svelte/compose-with-tanstack-store` — atom interop and per-slice subscription.
236
+ - `tanstack-table/core/pagination` / `filtering` / `sorting` — feature deep dives.