Overview
Options control how nuqs updates the URL and interacts with your framework’s routing system. They can be set at three levels:- Hook level - applies to all state updates for that hook
- Parser level - using
.withOptions()on a parser - Update level - passed to individual
setStatecalls (overrides hook/parser options)
Available options
All options are defined inpackages/nuqs/src/defs.ts:9-90:
history
Controls how URL updates affect browser history.'replace'
replace (default)
Replaces the current history entry. Multiple state updates are “squashed” into a single history point:
- Search/filter controls
- Pagination
- Any state that shouldn’t clutter history
push
Creates a new history entry for each update. Users can navigate state changes with back/forward buttons:
- Multi-step forms/wizards
- Tab navigation
- State that represents distinct “pages”
Override per update
packages/nuqs/src/defs.ts:10-18 and README.
shallow
This option only applies to Next.js. Other frameworks ignore it.
true
true (default) - Client-only updates
URL updates stay on the client. No network requests are made:
- UI state (filters, sorting, pagination)
- Interactive controls
- Client-side only features
false - Server updates
URL updates trigger a server request and re-render Server Components:
- Server Components depend on the search param
- You need to re-fetch data based on URL state
- SEO requires server-rendered content
packages/nuqs/src/defs.ts:27-34 and README.
scroll
Controls whether the page scrolls to top after a URL update.false
Unlike Next.js router’s navigation methods which scroll by default, nuqs defaults to
false to preserve the user’s scroll position.packages/nuqs/src/defs.ts:20-25.
throttleMs (deprecated)
packages/nuqs/src/defs.ts:37-53.
limitUrlUpdates
Controls rate limiting of URL updates to prevent browser history API throttling.throttle(50) (or throttle(120) for Safari)
Why rate limiting?
Browsers rate-limit the History API to prevent abuse:- Chrome/Firefox: ~50 updates/second is safe
- Safari 17+: max 100 updates per 10 seconds (~120ms throttle recommended)
- Safari <17: max 100 updates per 30 seconds (~320ms throttle recommended)
Throttle
Ensures a maximum update frequency. State updates are immediate; only URL updates are throttled:State updates are always instant to keep UI responsive. Only URL/server updates are throttled.
Debounce
Waits for a pause in updates before applying to URL:- Search inputs (avoid server requests on every keystroke)
- Expensive operations
- Any high-frequency updates
Override per update
packages/nuqs/src/defs.ts:55-68 and README.
startTransition
Enables React 18+ transitions for loading states during server updates.Only useful when combined with
shallow: false in Next.js, or for wrapping navigation events in other frameworks.Usage with useTransition
How it works
When you update state:- React state updates immediately (optimistic)
- URL updates (throttled)
- Server Components re-render with new searchParams
isLoadingistruewhile server is responding- Client receives RSC payload and updates
- Loading spinners during server updates
- Optimistic UI updates
- Pending states for async operations
packages/nuqs/src/defs.ts:70-78 and README.
clearOnDefault
Controls whether setting state to the default value clears it from the URL.true
When a parser has a default value, setting state to that default removes the key from the URL:
Why default to true?
Keeps URLs clean by not showing default values:When to use false
Set tofalse when you need explicit URLs that don’t change meaning if defaults change:
packages/nuqs/src/defs.ts:80-89.