Adapters
Using nuqs in your React framework of choice
Since version 2, you can now use nuqs in the following React frameworks, by
wrapping it with a NuqsAdapter
context provider:
Next.js
App router
Wrap your {children}
with the NuqsAdapter
component in your root layout file:
Pages router
Wrap the <Component>
page outlet with the NuqsAdapter
component in your _app.tsx
file:
Unified (router-agnostic)
If your Next.js app uses both the app and pages routers and the adapter needs to be mounted in either, you can import the unified adapter, at the cost of a slightly larger bundle size (~100B).
The main reason for adapters is to open up nuqs to other React frameworks:
React SPA
Example, with Vite:
Remix
React Router
Note: If you are using react-router v7, please import the NuqsAdapter
from nuqs/adapters/react-router/v7
Testing
Documentation for the NuqsTestingAdapter
is on the testing page.