[email protected] is available, try it now:
It’s packing exciting features & improvements, including:
- Support for other React frameworks: Next.js, React SPA, Remix, React Router, and more to come
- A built-in testing adapter to unit-test your components in isolation
- Bundle size improvements
- Interactive documentation, with community parsers
Hello, React! 👋 ⚛️
nuqs started as a Next.js-only hook, and v2 brings compatibility for other React frameworks:
- Next.js 14 & 15 (app & pages routers)
- React SPA
- Remix
- React Router
No code change is necessary in components that use nuqs hooks, making them universal across all supported frameworks.
The only new requirement is to wrap your React tree with an adapter for your framework.
Example for a React SPA with Vite:
The adapters documentation has examples for all supported frameworks.
Testing
One of the major pain points with nuqs v1 was testing components that used its hooks.
Nuqs v2 comes with a built-in testing adapter that mocks URL behaviours, allowing you to test your components in isolation, outside of any framework runtime.
You can use it with any unit testing framework that renders React components (I recommend Vitest & Testing Library).
The adapter conforms to the setup / act / assert testing strategy, allowing you to:
- Set the initial URL search params
- Let your test framework perform actions on your component
- Asserting on how the URL was changed as a result
Breaking changes & migration
The biggest breaking change is the introduction of adapters. Another one is related to deprecated APIs.
The next-usequerystate
package that started this journey is no longer updated.
All updates are now published under the nuqs
package name.
The minimum version of Next.js supported is now 14.2.0. It is compatible with
Next.js 15, including the async searchParams
page prop in the server-side cache.
There are some important behaviour changes, based on feedback from the community:
clearOnDefault
is nowtrue
by defaultstartTransition
no longer setsshallow: false
parseAsJson
now requires a validation function
Read the complete migration guide to update your applications.
Bundle size improvements
By moving to ESM-only, and dropping hacks needed to support older versions of Next.js, the bundle size is now 20% smaller than v1. It’s also side-effects free and tree-shakable.
What’s next?
The community and I have a lot of ideas for the future of nuqs, including:
- A unified, scalable, type-safe routing experience in all supported React frameworks
- Community-contributed parsers & adapters
- New options: debouncing, global defaults override
- Middleware to migrate old URLs to new ones
- Better Zod integration for type-safe & runtime-safe validation
Thanks
I want to thank sponsors, contributors and people who raised issues and discussions on GitHub and X/Twitter. You are the growing community that drives this project forward, and I couldn’t be happier with the response.
Sponsors
- Pontus Abrahamsson, founder of Midday.ai
- Carl Lindesvard, founder of OpenPanel
- Robin Wieruch, author of The Road to Next
- Yoann Fleury
- Sunghyun Cho
- Jalol
Thanks to these amazing people, I’m able to dedicate more time to this project and make it better for everyone. Join them on GitHub Sponsors!
Contributors
Huge thanks to @andreisocaciu, @tordans, @prasannamestha, @Talent30, @neefrehman, @chbg, @dopry, @weisisheng, @hugotiger, @iuriizaporozhets, @rikbrown, @mateogianolio, @timheerwagen, @psdmsft, and @psdewar for helping!