history-state
history-state allows you to monitor and make changes to a page’s history state.
Install
$ npm install history-state
API
By default, the mechanisms used are history.pushState
and window.onpopstate
, with older browsers falling back to location.hash
and window.onhashchange
. This behaviour can be overridden by passing the constructor an options object, detailed below.
var state = // Use only location.hash/onhashchange… hash: true // …or use only history.pushState/onpopstate. pushState: true state state // Toggle the window listeners.statestatestart