Troubleshooting
Common issues and solutions
Tip
Check out the list of known issues and solutions.
Pages router
Because the Next.js pages router is not available in an SSR context, this
hook will always return null
(or the default value if supplied) on SSR/SSG.
This limitation doesn’t apply to the app router.
Caveats
Different parsers on the same key
Hooks are synced together on a per-key basis, so if you use different parsers on the same key, the last state update will be propagated to all other hooks using that key. It can lead to unexpected states like this:
We recommend you abstract a key/parser pair into a dedicated hook to avoid this, and derive any desired state from the value:
Client components need to be wrapped in a <Suspense>
boundary
You may have encountered the following error message from Next.js:
Components using hooks like useQueryState
should be wrapped in <Suspense>
when rendered within a page component. Adding the ‘use client’ directive to the page.tsx file is the immediate fix to get things working if you are defining components that use client-side features (like nuqs or React Hooks):
However, the steps below indicate the optimal approach to get better UX: separating server and client files (and moving client side code as low down the tree as possible to pre-render the outer shell).
The recommended approach is:
- Keep page.tsx as a server component (no
'use client'
directive) - Move client-side features into a separate client file.
- Wrap the client component in a
<Suspense>
boundary.