A table that forgets its sorting and filters on reload cannot be shared as a link. @amjadiqbal/tanstack-table-url-state keeps a TanStack Table v9 table's state in the URL search params [1].
What it syncs
- Sorting:
sort=-total,customer(-means descending) - Global filter:
q=acme - Column filters:
f.status=paid - Page and size:
page=3,size=50 - Hidden columns:
hide=placed,email
Table changes update the URL; back/forward and links update the table. Defaults are left out, and filter typing reaches the URL after 300 ms.
Quick start
npm i @amjadiqbal/tanstack-table-url-state const { tableOptions } = useTableUrlState() const table = useTable({ features, columns, data, ...tableOptions }) It works with TanStack Router through an adapter [2], or with plain URLSearchParams [3] and the History API [4].
Export
CSV export covers the visible columns and filtered rows. XLSX lives in a separate entry that you load with a dynamic import(). CSV cells starting with =, +, - or @ get a leading apostrophe so spreadsheets do not run them.
Limits
- Malformed params such as
page=abcare ignored, not thrown. - Not covered yet: TanStack Start (SSR) apps and Solid/Vue/Svelte adapters.
MIT license. Peer dependencies: React 18+ and @tanstack/react-table 9.x. Source: urlshortly.com/OqkGc (docs: urlshortly.com/QhFzJ).

