useListQuery
v0.64.0, changelogBetaA server-paged list's query kept in the URL, so a filtered view is a link: page, limit, sortBy, order and search, read through list-query's grammar.
Table
Install
npx shadcn add @syncrobotic/use-list-query Also installs: @syncrobotic/list-query, @syncrobotic/use-debounce
Overview
When to use
- A list page whose filtered view should be a link people can share.
- Back and forward that restore the search, sort and page.
Use something else
- The grammar alone, with no React (a server component, a request): List query.
- A list inside a dialog: pass
memoryAdapter(), so the page's URL is left alone.
Usage rules
- Bind the search box to
searchandsetSearch: the box answers every key, the URL and the request wait for the pause. Clearing never waits. - A new search, sort, limit or filter goes back to page 1; only
setPagekeeps the rest. - In Next.js pass an adapter on the router (
useSearchParams,useRouter,usePathname), so navigation goes through it; /docs/nextjs/data has the code. - Request with
query, not with the box's text: the query is what the URL says.
Changelog
- 0.64.02026-12-01Formatted with Prettier (class order sorted); the code is unchanged.
- 0.55.02026-11-27First release: the query from the URL through an adapter (
historyAdapterby default,memoryAdapter, or your router's), the search text ahead of the URL with a debounce, and a new search, sort, limit or filter back on page 1.setQueryanduseSearchTextfor controlled blocks.