Browser debugging
You can enable debug logs in the browser by setting thedebug item in localStorage
to nuqs, and reload the page.
useQueryState and useQueryStates will be prefixed with
[nuq+], along with other internal debug logs.
Unlike the
debug package, this will not work with wildcards, but
you can combine it: localStorage.setItem('debug', '*,nuqs')- State updates and their values
- URL synchronization events
- Parser operations
- Queue processing
- History API calls
Performance markers
User timings markers are also recorded when debug mode is enabled, for advanced performance analysis using your browser’s devtools. To view these markers:- Open your browser’s DevTools
- Go to the Performance tab
- Record a session while interacting with your app
- Look for
nuqsmarkers in the timeline
Server-side debugging (Node.js)
Debug logs apply in any Node environment: server-side rendering (SSR), React Server Components (RSC), or when usingnuqs/server. Hooks like
useQueryState and useQueryStates can run on the server in these contexts.
Enable logs by setting the DEBUG environment variable so it contains nuqs:
DEBUG=nuqs in your .env file or configure it through
your hosting environment.
Debug log format
Debug logs use a printf-style format with the following specifiers:%s- String%d- Number (integer or float)%f- Float%O- Object (serialized as JSON)
sprintf function from /home/daytona/workspace/source/packages/nuqs/src/lib/debug.ts:24:
Common debugging scenarios
State not updating
If your state isn’t updating as expected:- Enable debug mode
- Check the console for
[nuq+]logs - Look for:
- Parse errors (invalid values)
- Queue processing logs
- URL update logs
URL not synchronizing
If the URL isn’t reflecting your state changes:- Check if you’ve wrapped your app with the correct adapter
- Enable debug mode and look for adapter-related logs
- Verify throttling settings aren’t delaying updates too much
Multiple adapter contexts
If you see warnings about multiple adapter contexts:- This may indicate duplicate
nuqsversions in your dependencies - Check if there are multiple copies of the nuqs package in node_modules
- Use
npm ls nuqsorpnpm why nuqsto identify duplicates
Sharing debug logs
When opening an issue on GitHub, please include debug logs to help diagnose the problem:- Enable debug mode as described above
- Reproduce the issue
- Copy the relevant console output
- Include it in your issue report
Be sure to remove any sensitive information (API keys, personal data, etc.)
from the logs before sharing.
Disabling debug logs
To disable debug logs: In the browser:DEBUG environment variable:
Private browsing mode
In some environments like Safari’s private browsing mode,localStorage may not be available.
The debug functionality gracefully handles this case and will simply not enable debug logs.
From /home/daytona/workspace/source/packages/nuqs/src/lib/debug.ts:41: