-
-
Notifications
You must be signed in to change notification settings - Fork 119
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Serializer is returning an empty string on default search params in v2 #715
Comments
That's a consequence of the option It's true that this might be counter-intuitive for the serializer, if one wants to create a link that does hardcode the defaults in the URL. Unfortunately for now, the serializer does not accept global options, like useQueryStates, but it should if we want to support urlKeys as well. In the mean time, the alternative would be to pass the const serialize = createSerializer({
foo: parseAsString.withOptions({ clearOnDefault: false }),
bar: parseAsInteger.withOptions({ clearOnDefault: false })
}) I'll see what I can do to add global options support this week. |
Thanks @franky47 - setting clearOnDefault to false indeed fix the issue. Somehow my next implementation doesn't re-render unless the params are hardcoded. |
Could you elaborate that last part? The useQueryState(s) hooks should follow the URL, and if a key isn't in the query string, return the default value if specified (or null otherwise). |
I'm passing the |
@blechatellier Thank you for posting this! I was struggling with the same problem. |
I've added a fix for this in #720.
You can try it here:
|
@franky47 awesome, cleaner this way. |
🎉 This issue has been resolved in version 2.1.0 🎉 The release is available on: |
Thanks @franky47 🙏 |
Context
What's your version of
nuqs
?[email protected]
What framework are you using?
✅ Next.js (app router)
Which version of your framework are you using?
[email protected]
Description
After upgrading to v2, the serializer returns an empty string when search params are using the default.
The text was updated successfully, but these errors were encountered: