Closed anaclumos closed 3 weeks ago
The clearOnDefault
can be applied per-parser using parseAsFloat.withOptions
, though it won't do anything on the server: it's a URL update options (maybe we should make this more clear in the docs).
Regarding urlKeys, at the moment it's only implemented in useQueryStates (see #672), and I agree that having a single source of truth would be the best way. I'm not sure what kind of API that would look like, open to suggestions and PRs.
I guess I'll export an object at that file with all of the configs for now. Would see some sort of "global" option or "parser-specific-global" option so that I don't need to pass around the same object over and over.
Great work btw, been sponsoring you!
Thank you for the sponsorship! 🙏
Would see some sort of "global" option
This is coming after V2 lands, in the form of overridable global defaults for options. The adapters (which are a context provider) will forward them to the hooks, so it should look something like:
<NuqsAdapter globalOptions={{ clearOnDefault: false }} >
{children}
</NuqsAdapter>
Also please note that clearOnDefault will be set to true by default in V2, per user feedback.
:tada: This issue has been resolved in version 2.1.0 :tada:
The release is available on:
Context
What's your version of
nuqs
?1.20.0
Next.js information (obtained by running
next info
):Are you using:
basePath
option in your Next.js configwindowHistorySupport
flag in your Next.js configDescription
How can I use
clearOnDefault
andurlKeys
? Or to be more precise, I want to have a one single-source-of-truth, next to, for example, this: