rootr

0.3.0 • Public • Published

rootr

CircleCI

Overview

A router for single page apps:

  1. Wraps DOM APIs for window and history.
  2. Routes defined with paths, similar to express.
  3. 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') )
}])

Package Sidebar

Install

npm i rootr

Weekly Downloads

1

Version

0.3.0

License

MIT

Last publish

Collaborators

  • jcfisher007