Framework-free SPA-style page loading for statically generated sites.
$ yarn add static-navigator
Call this function in every file that needs the navigator functionality. Each link on the page will be intercepted if it's an internal link.
staticNavigator expects a DOM Node with an id of
slot both on the current document and in the next document. This allows a fragment to be extracted and mounted in place so things like navigation bars or footers can remain in place. This also prevents a need for a separate document with just the fragment.
Returns an object with
Attach a callback to navigator events to handle errors and present loading states.
||nextHref||Called just before the url is pushed to the history stack|
||-||Called after the HTML has been attached to the
||Error||Called when there is trouble mounting the new document to the
||Error||Called when there is trouble fetching the new document|
A convenience method that will let you know if you're currently subscribed to an event.
A convenience method that will give you all the events that you're currently subscribed to.