rootr
v0.3.0
Published
Router for single page app.
Downloads
9
Maintainers
Readme
rootr
Overview
A router for single page apps:
- Wraps DOM APIs for window and history.
- Routes defined with paths, similar to express.
- Content loaded async. Works with code splitting.
Usage
Setup
var {loadContent, loadRoutes} = require('rootr')
let routes = [{
path: '/',
load: () => System.import('./pages/home')
} {
path: '*',
load: () => System.import('./pages/error_not_found')
}]
loadRoutes( routes )
Open path programmically
import {location} from 'rootr'
location.open('/buckets/1')
Use redirect
to change the URL without adding an entry to the history state.
location.redirect('/buckets')
Replace routes
Change the routes.
loadRoutes([{
path: '/',
load: loadContent( System.import('./pages/home') )
}])