Next.js Discord

Discord Forum

window.location.replaceState (and push) causes page reload

Unanswered
Gray Wagtail posted this in #help-forum
Open in Discord
Gray WagtailOP
If I call window.location.replaceState, or the push one, it causes Next to reload the page. This wasn't a thing in v14 that we use at work.
So any component that uses useSearchParams re-renders when I just want to change the URL without side-effects.
Seems like a regression/bug to me, why are we doing this?

1 Reply

Gray WagtailOP
Weirdly enough, the router.replace function seems more stable in this regard. No lag when I use it, although it of course causes a server fetch every time it's changed.