Skip to content

Handling Arrays in Query Parameters with Nuqs Library #517

Answered by franky47
SergGrey1992 asked this question in Q&A
Discussion options

You must be logged in to vote

If you're talking about multiple keys in the URL giving an array output like URLSearchParam does, this is not currently supported, discussion about API ideas is here: #484

There is however a parseAsArrayOf parser that lets you put an array under a single search param key: https://nuqs.47ng.com/docs/parsers#arrays

As for best practices with setting state arrays, it's the same as for a useState: no mutation of the array (so no push/pop), always return a new instance with the added item or filter out the one to remove.

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
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
2 participants