Probably you even no need to use this but it's ok :)
Advantages:
- NO dependencies
- NO conflicts
- NO overrides
- just include as source or module
- IE6+, Firefox 2+
... as source <script src="router.js"></script>
... as module yarn add vanilla-spa-router
Use window._Router(ops)
or new Router(ops)
to access to routing
mode: 'history'(default) or 'hash'
Choose the way of routingbase: '/'(default)
Set base directory
.init(ops)
Rebind your options accordingly.start()
Start working with router using History API or#anchor
.use(String route, Function middleware)
Subscribe for router updates for exact path with needed paramsmiddleware(Object data)
- Receives transformed data from path name. You can continue working straight with Router usingthis
inside middleware.navigate(String path)
Replaces you to the needed location