@transformation-dev/locationchange
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published

@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/locationchange

Usage

import '@transformation-dev/locationchange';

Package Sidebar

Install

npm i @transformation-dev/locationchange

Weekly Downloads

7

Version

1.0.0

License

MIT

Unpacked Size

16 kB

Total Files

6

Last publish

Collaborators

  • lmaccherone