1.0.0 • Published 3 years ago

@issimo/add-history-listener v1.0.0

Weekly downloads
1
License
MIT
Repository
github
Last release
3 years ago

This package provides a simple api to subscribe to browser history events.

add-history-listener

size downloads npm GitHub

This package provides a simple API to subscribe to browser history events.

const cleanup = addHistoryListener((prev, next) => {
  console.log(next);
});

history.replaceState(42, undefined, "/somewhere#over-the-rainbow");
// Prints { state: 42, pathname: "/somewhere", hash: "#over-the-rainbow", ...other useful things}