Should serialize()
return the string ?
for all-nullish params? (+1 issue)
#767
-
tl;dr: should Hey there! Awesome library you've got there, finally found a reason to use it and i never think i'd be so happy writing a paginator component (though it is beautiful). Using nuqs 2.2.0 (coincidentally released 1 h before i installed it). I'm on Next.js and for this component experimenting with doing everything SSR, with just Here's some of my code, if of any use
```ts
const productDetailParamsParsers = {
section: parseAsStringLiteral(["section-1", "section-2"]),
page: pageIndexParser.withOptions({ clearOnDefault: false }).withDefault(0),
}
const productDetailUrlKeys = { section: "seccion", page: "pagina" } as const
export const productDetailParamsCache = createSearchParamsCache(productDetailParamsParsers, {
urlKeys: productDetailUrlKeys,
})
export const serializeProductDetailParams = createSerializer(productDetailParamsParsers, {
urlKeys: productDetailUrlKeys,
})
```
(Sorry for bad rendering in GitHub)
That Closing a certain modal clears certain search params, so for that i have to do <Link href={serializeProductDetailParams({ ...rest, section: null, page: undefined }) || "?"}> With that intro out of the way...
Thanks again for the awesome library! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
Regarding point 1, the idea was for the serializer to have the same behaviour as the hooks, which when clearing the URL, don't leave a dangling Regarding point 2, what you'd want is to render the default value of the parser in the resulting URL? That would be a very good addition, since |
Beta Was this translation helpful? Give feedback.
Here you go: #769
Code is quite beautiful btw