Description
Describe the bug
When router type is set to hash
, the browser navigation works fine in dev mode (pnpm run dev
). But the navigation is inconsistent/incorrect in build.
For example, from route #/
, if you navigate to /#route1
and go back to #/
by clicking on the back button of the browser, you can't go forward to #/route1
anymore using browser forward button (disabled).
Reproduction
- pnpx sv create
- Sveltekit minimal
- Set routing type to
hash
- Bundle strategy to
inline
and adapter set to@sveltejs/adapter-static
- create a route
route1
pnpm run build
pnpm run preview
- From
#/
go to#/route1
and come back to#/
using browser back button. You will see that you can't go forward to#/route1
using browser forward button
Minimal reproduction repo:
https://github.com/sateeshsai/hash-routing-issue
Logs
None
System Info
System:
OS: macOS 15.2
CPU: (12) arm64 Apple M2 Max
Memory: 537.56 MB / 32.00 GB
Shell: 5.9 - /bin/zsh
Binaries:
Node: 20.12.2 - /usr/local/bin/node
npm: 10.5.2 - /usr/local/bin/npm
pnpm: 9.0.5 - /usr/local/bin/pnpm
Browsers:
Chrome: 133.0.6943.54
Edge: 133.0.3065.59
Safari: 18.2
npmPackages:
@sveltejs/adapter-auto: ^4.0.0 => 4.0.0
@sveltejs/adapter-static: ^3.0.8 => 3.0.8
@sveltejs/kit: ^2.16.0 => 2.17.1
@sveltejs/vite-plugin-svelte: ^5.0.0 => 5.0.3
svelte: ^5.0.0 => 5.20.0
vite: ^6.0.0 => 6.1.0
Severity
blocking all usage of SvelteKit
Additional Information
No response