Query parameters in hash routing become permanent if used "as directed"
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 20.8k
- Forks
- 2.3k
- Avg merge
- 1d 16h
- Merged PRs (30d)
- 156
Description
Describe the bug
In https://github.com/sveltejs/kit/pull/13191 there is a spirited discussion between Rich and the author as to how to handle query parameters in hash based routing.
Again, that's your choice. I will not; I will get my query parameters from
page.url.searchParams, because I don't like to do work that's already been done for me.
Originally posted by @Rich-Harris in https://github.com/sveltejs/kit/issues/13191#issuecomment-2558122313
This implies that the intended "svelte" way to handle query parameters in hash based routing is with page.url.searchParams.
However -- when navigating between pages; the expected behaviour, ie, search parameters are deleted, does NOT occur. They become "permanent" search params.
Reproduction
- when opened, the footer says "You have no search params"
- click about page - "Your current query parameters are: aboutpage="
- click home - "Your current query parameters are: aboutpage="
Logs
System Info
System:
OS: Linux 5.0 undefined
CPU: (8) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
Memory: 0 Bytes / 0 Bytes
Shell: 1.0 - /bin/jsh
Binaries:
Node: 20.19.1 - /usr/local/bin/node
Yarn: 1.22.19 - /usr/local/bin/yarn
npm: 10.8.2 - /usr/local/bin/npm
pnpm: 8.15.6 - /usr/local/bin/pnpm
npmPackages:
@sveltejs/adapter-auto: ^6.0.0 => 6.1.1
@sveltejs/kit: ^2.22.0 => 2.43.7
@sveltejs/vite-plugin-svelte: ^6.0.0 => 6.2.1
svelte: ^5.25.0 => 5.39.8
vite: ^7.0.4 => 7.1.8
Severity
serious, but I can work around it
Additional Information
No response
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the behavior in the linked StackBlitz example, starting with src/routes/+layout.svelte and the documented navigation steps. Trace how query parameters are read during hash-based navigation; done means moving from About to Home no longer retains aboutpage= when the destination has no search parameters.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- frontend, web-dev
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100