@transformation-dev/locationchange
v1.0.0
Published
Adds a `locationchange` event to `window` that is dispatched whenever the URL changes even when `pushState` or `replaceState` or clicking the back button caused the change. Also adds `pushstate` and `replacestate` events to `window` in case you want to li
Maintainers
Readme
@transformation-dev/locationchange
When you import this package, it adds a locationchange event to window that is dispatched whenever the URL changes
even when calling pushState or replaceState caused the change as well as when the browser's back or forward buttons are used.
It also adds pushstate and replacestate events to window in case you want to listen to those specifically.
This packages is particularly usefull when you are using a single-page application (SPA) router that manipulates the URL
using the browser's history API ( history.pushState() and history.replaceState()), but does not trigger a page reload.
Installation
npm install @transformation-dev/locationchangeUsage
import '@transformation-dev/locationchange';