Created
June 30, 2023 10:09
-
-
Save deviationist/16921ea69a9685bd1b5eba50d2581319 to your computer and use it in GitHub Desktop.
A bare simple class made for Next.js with static methods to use as a shallow router (triggering changes in the URL without Next acting on them).
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export class ShallowRouter { | |
static push(url: string): void { | |
window.history.pushState({ ...window.history.state, as: url, url }, '', url); | |
} | |
static replace(url: string): void { | |
window.history.replaceState({ ...window.history.state, as: url, url }, '', url); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment