Skip to content

Using native javascript window.history.pushState but getting issue with Back button behaviour #1809

Discussion options

You must be logged in to vote

I ran into a similar issue. It appears in order for Inertia to remember the state of the URL you have to use their Link or router.

Here's what I ended up with to mimic window.history.replaceState.
I'm thinking you could do the same without replace.

router.visit(`${window.location.pathname}${queryString}`, {
    preserveState: true,
    preserveScroll: true,
    replace: true,
    only: [],
});

I feel like they need to document this behavior better. They really don't have much information around how to handle query params without refreshing the page.

Replies: 2 comments 3 replies

Comment options

You must be logged in to vote
1 reply
@mgtcampbell
Comment options

Comment options

You must be logged in to vote
2 replies
@mgtcampbell
Comment options

@nicholashamilton
Comment options

Answer selected by mgtcampbell
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
None yet
3 participants