Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create a window.location.replace() using sveltekit

Is there a way to create window.location.replace in SvelteKit, like we can use goto()?

I want a way to not save the current URL in history. The current URL has query strings that change and the user cannot use the back button to go to the previous page. Instead, just go to the page with different query strings.

Edit: I am using history.pushState() and history.replaceState() to not save the URLs in history. I wish there was a built-in way in SvelteKit to do this.

like image 209
da-nav Avatar asked Oct 13 '25 05:10

da-nav


1 Answers

There is a replaceState parameter on goto that may do what you're looking for.

goto('/wherever', { replaceState: true });

Looks like the options passed to goto could be better documented, I'll see if I can fix that.

Current docs

like image 112
Geoff Rich Avatar answered Oct 14 '25 18:10

Geoff Rich