-
Notifications
You must be signed in to change notification settings - Fork 147
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Feature] useSearchParams support key only param #209
Comments
Yeah this is a good idea. Looking at the browser APIs they use an empty string. However since we aren't only passing strings and might want to differentiate from an empty string. I'd love to know if there is precedence here in other libraries. |
possibly |
@ryansolid Next.js has a nice ReadonlyURLSearchParams. Current implementation only returns the last value if there are multiple keys with the same name. (e.g. Implementing similar API to URLSearchParams would give developers a choice between URLSearchParams.get() and URLSearchParams.getAll(). also Thanks for an amazing framework! |
I ran into this usecase and tried messing around for a solution. Just making It seems that nextjs and sveltekit both just give you a URLSearchParams object without a builtin way to set search params. Users just have to roll their own function to change the url. I also ended rolling my own function with the I think a better |
Describe the bug
Currently, there is no way to set the query string to something like
domain.tld?page=1&latest
. solid-router should support key-only params as it is valid in the URI spec and there are legitimate use cases for them.Your Example Website or App
https://github.com/solidjs/solid-router
Steps to Reproduce the Bug or Issue
Setting
setSearchParams({ page: 1, latest: undefined })
,setSearchParams({ page: 1, latest: null })
orsetSearchParams({ page: 1, latest: "" })
completely removes thelatest
param resulting in?page=1
.Expected behavior
setSearchParams({ page: 1, latest: null })
should result in?page=1&latest
andsearchParams
should be represented as{ page: 1, latest: null }
The text was updated successfully, but these errors were encountered: