-
Adding a support for initial value would help to simplify some components at least in our case. Default value does not work in our case, because we want to set the value to null sometimes and in that case nuqs will fallback to the default value. We'd like to have initial value, so we don't need to use useEffect or similar approach to "initialize" the state. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 4 replies
-
I was sure we already had a discussion about this topic, but it must have been on another platform. TL;DR: no, the URL is the source of truth, so an initial value doesn't make sense: the value is whatever the URL contains (or doesn't contain, and therefore returns You can skip the default value and have the hook return |
Beta Was this translation helpful? Give feedback.
I was sure we already had a discussion about this topic, but it must have been on another platform.
TL;DR: no, the URL is the source of truth, so an initial value doesn't make sense: the value is whatever the URL contains (or doesn't contain, and therefore returns
null
or falls back to the default value if specified).You can skip the default value and have the hook return
null
when there is no query in the URL, but if your use-case warrants that a given value in the URL explicitly maps tonull
, then nuqs isn't able to do that.