@tofandel/hash-router
v0.1.4
Published
A frontend router for the hash change event
Downloads
2
Readme
@tofandel/hash-router
A frontend router for the hash change event
Example
import HashRouter from "@tofandel/hash-router";
const router = new HashRouter({
'/': renderHome,
'/login': showLoginDialog,
'*': fallbackRoute
})
router.addRoute('/another', anotherRouteCb);
router.on("routed", function (hash, event) {
console.log("Route has changed!", hash, event)
})
router.on("not-found", function (hash, event) {
console.log("Didn't find a route", hash, event) // This won't ever fire if the '*' route is set
})
router.started.then(() => {
console.log('Router is ready');
router.go('/login');
})
Installation
npm install @tofandel/hash-router