Overview of Breaking Changes
- Adapters are now required
- Minimum Next.js version: 14.2.0
- Behaviour changes
- ESM-only package
- Deprecated exports removed
nuqs/parsersrenamed tonuqs/server- Type changes
Adapters Required
Next.js App Router
Wrap your{children} with the NuqsAdapter component in your root layout:
src/app/layout.tsx
Next.js Pages Router
Wrap the<Component> page outlet in your _app.tsx file:
src/pages/_app.tsx
Unified Adapter (Both Routers)
If your Next.js app uses both app and pages routers, import the unified adapter:This comes with a slightly larger bundle size (~100B) compared to the router-specific adapters.
Migration Steps
Choose the appropriate adapter for your Next.js router and wrap your app as shown in the Adapters Required section above.
- import { parseAsInteger, createSearchParamsCache } from 'nuqs/parsers'
+ import { parseAsInteger, createSearchParamsCache } from 'nuqs/server'
This change reflects that the export now contains more than just parsers and is specifically for server-side code.
- import { queryTypes } from 'nuqs'
+ import { parseAsString, parseAsInteger } from 'nuqs'
- useQueryState('q', queryTypes.string.withOptions({ ... }))
- useQueryState('page', queryTypes.integer.withDefault(1))
+ useQueryState('q', parseAsString.withOptions({ ... }))
+ useQueryState('page', parseAsInteger.withDefault(1))
If you’re using
startTransition, you now need to explicitly set shallow: false to send updates to the server:Minimum Next.js Version
Early versions of Next.js 14 had instability with shallow routing. Supporting those versions required workarounds and performance penalties, which have been removed in v2.Behaviour Changes
startTransition No Longer Implies shallow: false
In v1, settingstartTransition automatically set shallow: false. This is no longer the case in v2 to align with other frameworks that don’t have shallow/deep routing concepts.
Before (v1):
“use client” Directive Added
The"use client" directive is now included in the main nuqs import. Server-side code must import from nuqs/server to avoid errors:
nuqs/server for all server-side code:
ESM Only
nuqs v2 is now an ESM-only package. This shouldn’t affect most Next.js users (ESM supported since Next.js 12), but if you’re bundling nuqs into an intermediate CommonJS library, you may encounter:Deprecated Exports Removed
queryTypes Object
ThequeryTypes object has been removed in favor of individual parser exports for better tree-shaking.
Before:
subscribeToQueryUpdates
This internal helper has been removed. Next.js 14.1.0+ makesuseSearchParams reactive to shallow updates, making this function redundant.
nuqs/parsers Renamed
Thenuqs/parsers export has been renamed to nuqs/server to better reflect its purpose.
Find and replace:
Debug Printout Detection
The debug logging detection now only checks fornuqs in localStorage.debug (not the old next-usequerystate name).
Update your local environment:
Type Changes
The following type changes may affect your TypeScript code:- The
Optionstype is no longer generic UseQueryStatesOptionsis now a type (not an interface) and is generic over the object passed touseQueryStatesparseAsJsonnow requires a runtime validation function to infer the parsed JSON data type
Testing Improvements
While not a breaking change, v2 introduces a dedicated testing adapter that makes unit testing much easier!
NuqsTestingAdapter:
New Framework Support
Beyond Next.js, nuqs v2 now supports:- React SPA (Vite, Create React App)
- Remix
- React Router (v6 and v7)
- TanStack Router
Summary
The migration to v2 primarily involves:- Adding an adapter wrapper to your app
- Updating
nuqs/parsersimports tonuqs/server - Ensuring Next.js ≥14.2.0
- Explicitly setting
shallow: falsewhen usingstartTransition - Replacing deprecated
queryTypeswith individual parsers