visionmedia / page.js

Micro client-side router inspired by the Express router
http://visionmedia.github.com/page.js
7.67k stars 687 forks source link

Change route url without refreshing #588

Closed plckr closed 3 years ago

plckr commented 3 years ago

Hello,

is it possible to change the url without calling again the route?

Example, I have a route that takes 2 arguments /id/slug If slug is incorrect, I want to correct it, but don't want to run the same code to check Only want to correct the url and continue the code.

plckr commented 3 years ago

Okay, I found the answer. Using history.replaceState(null, '', url); manages to change the url without triggering a refresh

For any1 interested, here's an article https://developer.mozilla.org/en-US/docs/Web/API/History/replaceState