Installation
Wrap your app with the adapter
Import and wrap your application with
NuqsAdapter in your root entry file:src/main.tsx
The adapter must wrap your entire application to provide the necessary context for nuqs hooks.
Version Requirements
- React:
>=18.2.0or^19.0.0-0
Features
History Syncing
By default, the React adapter only syncs with nuqs internal updates. To enable syncing with external History API updates, useenableHistorySync():
src/main.tsx
useOptimisticSearchParams to react to third-party code that directly updates the History API.
Full Page Navigation on Shallow False
By default, settingshallow: false uses the History API. To trigger full page navigations instead:
src/main.tsx
Browser Back/Forward Support
The adapter automatically listens topopstate events, so the browser’s back and forward buttons work out of the box:
How It Works
The React adapter:- Reads search params directly from
location.search - Updates the URL using the History API (
history.pushState/history.replaceState) - Listens to
popstateevents for back/forward navigation - Uses an internal event emitter to sync state across components
- Batches and throttles URL updates to avoid rate limiting
Usage with React Router
If you’re using React Router, use the dedicated React Router adapters instead: These adapters integrate more deeply with React Router’s navigation system.Examples
Search with Debouncing
Filters with Multiple States
Troubleshooting
State not syncing across components
Make sure all components using nuqs hooks are children of theNuqsAdapter.
URL not updating
Check that:- Your app is running in a browser environment (not SSR)
- The
NuqsAdapteris properly mounted - You’re not accidentally calling
preventDefault()or similar on navigation events