Skip to main content

Overview

Options control how nuqs updates the URL and interacts with your framework’s routing system. They can be set at three levels:
  1. Hook level - applies to all state updates for that hook
  2. Parser level - using .withOptions() on a parser
  3. Update level - passed to individual setState calls (overrides hook/parser options)

Available options

All options are defined in packages/nuqs/src/defs.ts:9-90:

history

Controls how URL updates affect browser history.
Default: 'replace'

replace (default)

Replaces the current history entry. Multiple state updates are “squashed” into a single history point:
This is ideal for:
  • 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:
This is ideal for:
  • Multi-step forms/wizards
  • Tab navigation
  • State that represents distinct “pages”

Override per update

From packages/nuqs/src/defs.ts:10-18 and README.

shallow

This option only applies to Next.js. Other frameworks ignore it.
Controls whether URL updates notify the server.
Default: true

true (default) - Client-only updates

URL updates stay on the client. No network requests are made:
This is the recommended default for:
  • 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:
This is needed when:
  • Server Components depend on the search param
  • You need to re-fetch data based on URL state
  • SEO requires server-rendered content
From packages/nuqs/src/defs.ts:27-34 and README.

scroll

Controls whether the page scrolls to top after a URL update.
Default: false
Unlike Next.js router’s navigation methods which scroll by default, nuqs defaults to false to preserve the user’s scroll position.
From packages/nuqs/src/defs.ts:20-25.

throttleMs (deprecated)

Deprecated in favor of limitUrlUpdates. Use throttle() helper instead.
Limits how frequently the URL is updated (in milliseconds).
From packages/nuqs/src/defs.ts:37-53.

limitUrlUpdates

Controls rate limiting of URL updates to prevent browser history API throttling.
Default: 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)
nuqs automatically detects Safari and adjusts the default:

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:
Debouncing is ideal for:
  • Search inputs (avoid server requests on every keystroke)
  • Expensive operations
  • Any high-frequency updates

Override per update

Values lower than 50ms are ignored to prevent rate-limiting issues.
From 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:
  1. React state updates immediately (optimistic)
  2. URL updates (throttled)
  3. Server Components re-render with new searchParams
  4. isLoading is true while server is responding
  5. Client receives RSC payload and updates
This enables:
  • Loading spinners during server updates
  • Optimistic UI updates
  • Pending states for async operations
From packages/nuqs/src/defs.ts:70-78 and README.

clearOnDefault

Controls whether setting state to the default value clears it from the URL.
Default: 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 to false when you need explicit URLs that don’t change meaning if defaults change:
This ensures URLs remain stable even if you change the default value in the future. From packages/nuqs/src/defs.ts:80-89.

Combining options

You can combine multiple options for fine-grained control:

Option precedence

When the same option is specified at multiple levels:
Precedence: Update level > Hook level > Parser level > Default