@sebastbake/add-history-listenerdeprecated

Subscribe to browser history.

Usage no npm install needed!

<script type="module">
  import sebastbakeAddHistoryListener from 'https://cdn.skypack.dev/@sebastbake/add-history-listener';
</script>

README

This package provides a simple api to subscribe to browser history events. It's the window.

size downloads npm GitHub

add-history-listener

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}