URL search params aren't cleared on navigation with hash-based router
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
When using router.type === 'hash', typical navigations via href="#/..." don't clear search parameters in the same way that their pathname counterparts do.
Reproduction
Use the search bar in https://github.com/stephenlrandall/kit-inline-test and then return to the home page.
Logs
System Info
System:
OS: macOS 15.2
CPU: (16) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
Memory: 401.48 MB / 16.00 GB
Shell: 5.9 - /bin/zsh
Binaries:
Node: 20.8.0 - /usr/local/bin/node
npm: 10.1.0 - /usr/local/bin/npm
pnpm: 9.15.4 - ~/Library/pnpm/pnpm
Browsers:
Chrome: 131.0.6778.265
Edge: 131.0.2903.147
Safari: 18.2
npmPackages:
@sveltejs/adapter-auto: ^3.3.1 => 3.3.1
@sveltejs/adapter-static: ^3.0.8 => 3.0.8
@sveltejs/kit: ^2.15.3 => 2.15.3
@sveltejs/vite-plugin-svelte: ^4.0.4 => 4.0.4
svelte: ^5.18.0 => 5.18.0
Severity
serious, but I can work around it
Additional Information
A workaround is to prepend all links without search params with ?#/..., although this is obviously undesirable.
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 issue using the linked kit-inline-test project with the hash-based router and a search-bar navigation. Start by tracing hash-router handling for href="#/..." versus pathname navigation; done means returning home clears the URL search parameters without requiring the ?#/... workaround.
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
- 45/100