Skip to content
Discussion options

You must be logged in to vote

This is outlined in the docs: https://nuqs.47ng.com/docs/basic-usage#default-values

The main reason is, as you said, that null means no value. It's returned to indicate the absence of the search params key in the URL, or if the parser can't give you a meaningful value back (eg: using parseAsInteger, but the URL is ?foo=not-a-number).

null is also used to clear the search param from the URL on updates, a case where undefined would have been awkward:

const [state, setState] = useQueryState('foo')

// null clears the URL
setState(null)

// Using undefined would allow this, which is ambiguous:
setState()

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@tmkx
Comment options

@franky47
Comment options

Answer selected by franky47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants