Describe the bug
I have a modal which has links towards other pages.
// first-page/+page.svelte
<script>
import { pushState } from "$app/navigation";
import { page } from "$app/state";
function showPopup() {
pushState("", { showPopup: true });
}
</script>
<button onclick={showPopup}>show popup</button>
{#if page.state.showPopup}
<a href="/second-page">go to second page</a>
{/if}
This works fine, I correctly land in /second-page. When I go back with my browser's back button, I'm correctly redirected to /first-page, but the popup is still open while I need it to be closed.
I thought data-sveltekit-replacestate would solve my issue:
<a data-sveltekit-replacestate href="/second-page">go to second page</a>
But once on /second-page, after going back, the URL change to /first-page but the page doesn't load: the content of /second-page is still shown.
data-sveltekit-reload works as expected but the UX isn't great.
Is this behaviour expected? If so, is this shallow navigation actually doable without a full page reload?
Reproduction
See https://stackblitz.com/edit/sveltejs-kit-template-default-6v3iubbw?file=src%2Froutes%2F%2Bpage.svelte
Logs
System Info
System:
OS: macOS 15.5
CPU: (10) arm64 Apple M4
Memory: 89.84 MB / 16.00 GB
Shell: 5.9 - /bin/zsh
Binaries:
Node: 24.4.0 - /opt/homebrew/bin/node
pnpm: 10.13.1 - /opt/homebrew/bin/pnpm
Browsers:
Chrome: 138.0.7204.184
npmPackages:
@sveltejs/adapter-auto: ^6.0.0 => 6.0.1
@sveltejs/adapter-static: ^3.0.8 => 3.0.8
@sveltejs/kit: ^2.16.0 => 2.26.1
@sveltejs/vite-plugin-svelte: ^6.0.0 => 6.1.0
svelte: ^5.25.0 => 5.37.0
vite: ^7.0.0 => 7.0.6
Severity
annoyance
Additional Information
No response
Describe the bug
I have a modal which has links towards other pages.
This works fine, I correctly land in
/second-page. When I go back with my browser's back button, I'm correctly redirected to/first-page, but the popup is still open while I need it to be closed.I thought
data-sveltekit-replacestatewould solve my issue:But once on
/second-page, after going back, the URL change to/first-pagebut the page doesn't load: the content of/second-pageis still shown.data-sveltekit-reloadworks as expected but the UX isn't great.Is this behaviour expected? If so, is this shallow navigation actually doable without a full page reload?
Reproduction
See https://stackblitz.com/edit/sveltejs-kit-template-default-6v3iubbw?file=src%2Froutes%2F%2Bpage.svelte
Logs
System Info
System: OS: macOS 15.5 CPU: (10) arm64 Apple M4 Memory: 89.84 MB / 16.00 GB Shell: 5.9 - /bin/zsh Binaries: Node: 24.4.0 - /opt/homebrew/bin/node pnpm: 10.13.1 - /opt/homebrew/bin/pnpm Browsers: Chrome: 138.0.7204.184 npmPackages: @sveltejs/adapter-auto: ^6.0.0 => 6.0.1 @sveltejs/adapter-static: ^3.0.8 => 3.0.8 @sveltejs/kit: ^2.16.0 => 2.26.1 @sveltejs/vite-plugin-svelte: ^6.0.0 => 6.1.0 svelte: ^5.25.0 => 5.37.0 vite: ^7.0.0 => 7.0.6Severity
annoyance
Additional Information
No response