-
-
Notifications
You must be signed in to change notification settings - Fork 22
Open
Description
Describe the problem
Hey, thanks for the great library! It’s super handy for working with query parameters in SvelteKit.
I noticed that when you set a defaultValue, it updates the URL on the initial render if the parameter isn’t already there. For example:
const count = queryParam('count', {
encode: (value: number) => value.toString(),
decode: (value: string | null) => (value ? parseInt(value) : null),
defaultValue: 10,
});If I load /, it immediately changes the URL to /?count=10.
It would be nice to have an option to apply the default value without modifying the URL right away.
Describe the proposed solution
Maybe something like:
const count = queryParam('count', {
encode: (value: number) => value.toString(),
decode: (value: string | null) => (value ? parseInt(value) : null),
defaultValue: 10,
applyDefaultValueSilently: true,
});
This way, count would still default to 10 internally, but the URL stays clean until the user interacts with it.
Let me know if this makes sense or if there’s already a way to do this. Thanks again for your hard work on this library!
Metadata
Metadata
Assignees
Labels
No labels