Describe the bug
Using pushState from $app/navigation allows you to associate state with a history entry without navigating. After using it to "shallow" navigate to another page and then reload that page however, the associated state is still there. This makes that page behave differently from opening the url directly in a new browser tab.
As an example, I have gallery web site (repository link below). Home page lists the photos. Clicking a photo will show it in a lightbox and push the detail page url to history stack. Either closing the light box or clicking the Back button of the browser will close the light box and make the url history go back. Photo detail page shows the main photo and an "Other photos" section. Clicking a photo in this section behaves exactly like clicking a photo on home page.
Here's the issue: If we're on home page and click a photo with id 1, the lightbox opens and url changes to /photo/1. Reload (F5) the page and we're on /photo/1 detail page (with NO lightbox). Clicking a photo with id 2 from the "Other Photos" section will open the lightbox and url changes to /photo/2. Now if we close the lightbox, we expect it to close and url goes back to /photo/1. In fact, url does go back to /photo/1, but the lightbox is NOT closed, instead it shows the photo id 1. Closing the lightbox again will change the url back to home page, but the page content is that of the details photo page with id 1.
If we open /photo/1 in a new tab and do the same interactions, everything works normally.
Reproduction
https://github.com/locpdev/pushstate-bug
Logs
System Info
System:
OS: Windows 10 10.0.19045
CPU: (32) x64 AMD Ryzen 9 7950X 16-Core Processor
Memory: 45.34 GB / 63.12 GB
Binaries:
Node: 25.4.0 - C:\Program Files\nodejs\node.EXE
Yarn: 1.22.22 - C:\Users\Admin\AppData\Roaming\npm\yarn.CMD
npm: 11.7.0 - C:\Program Files\nodejs\npm.CMD
bun: 1.3.6 - C:\Users\Admin\.bun\bin\bun.EXE
Browsers:
Chrome: 146.0.7680.165
Edge: Chromium (140.0.3485.54)
Firefox: 149.0 - C:\Program Files\Mozilla Firefox\firefox.exe
Firefox Developer Edition: 127.0 - C:\Program Files\Firefox Developer Edition\firefox.exe
Internet Explorer: 11.0.19041.5794
npmPackages:
@sveltejs/adapter-auto: ^7.0.0 => 7.0.1
@sveltejs/kit: ^2.50.2 => 2.55.0
@sveltejs/vite-plugin-svelte: ^6.2.4 => 6.2.4
svelte: ^5.54.0 => 5.55.1
vite: ^7.3.1 => 7.3.1
Severity
blocking an upgrade
Additional Information
No response
Describe the bug
Using pushState from $app/navigation allows you to associate state with a history entry without navigating. After using it to "shallow" navigate to another page and then reload that page however, the associated state is still there. This makes that page behave differently from opening the url directly in a new browser tab.
As an example, I have gallery web site (repository link below). Home page lists the photos. Clicking a photo will show it in a lightbox and push the detail page url to history stack. Either closing the light box or clicking the Back button of the browser will close the light box and make the url history go back. Photo detail page shows the main photo and an "Other photos" section. Clicking a photo in this section behaves exactly like clicking a photo on home page.
Here's the issue: If we're on home page and click a photo with id 1, the lightbox opens and url changes to /photo/1. Reload (F5) the page and we're on /photo/1 detail page (with NO lightbox). Clicking a photo with id 2 from the "Other Photos" section will open the lightbox and url changes to /photo/2. Now if we close the lightbox, we expect it to close and url goes back to /photo/1. In fact, url does go back to /photo/1, but the lightbox is NOT closed, instead it shows the photo id 1. Closing the lightbox again will change the url back to home page, but the page content is that of the details photo page with id 1.
If we open /photo/1 in a new tab and do the same interactions, everything works normally.
Reproduction
https://github.com/locpdev/pushstate-bug
Logs
System Info
System: OS: Windows 10 10.0.19045 CPU: (32) x64 AMD Ryzen 9 7950X 16-Core Processor Memory: 45.34 GB / 63.12 GB Binaries: Node: 25.4.0 - C:\Program Files\nodejs\node.EXE Yarn: 1.22.22 - C:\Users\Admin\AppData\Roaming\npm\yarn.CMD npm: 11.7.0 - C:\Program Files\nodejs\npm.CMD bun: 1.3.6 - C:\Users\Admin\.bun\bin\bun.EXE Browsers: Chrome: 146.0.7680.165 Edge: Chromium (140.0.3485.54) Firefox: 149.0 - C:\Program Files\Mozilla Firefox\firefox.exe Firefox Developer Edition: 127.0 - C:\Program Files\Firefox Developer Edition\firefox.exe Internet Explorer: 11.0.19041.5794 npmPackages: @sveltejs/adapter-auto: ^7.0.0 => 7.0.1 @sveltejs/kit: ^2.50.2 => 2.55.0 @sveltejs/vite-plugin-svelte: ^6.2.4 => 6.2.4 svelte: ^5.54.0 => 5.55.1 vite: ^7.3.1 => 7.3.1Severity
blocking an upgrade
Additional Information
No response