3.0.3 • Published 3 years ago

rage-route v3.0.3

Weekly downloads
2
License
MIT
Repository
github
Last release
3 years ago

rage-route NPM version js-standard-style

Tiny, feature lite, super basic client router

Why rage?

This was built as a very feature light replacement for page.js.

Ships with es6 styled module and commonjs module for your rolling pleasure.

Install

$ npm install --save rage-route

Usage

import { addRoute, addRedirect, route, history } from 'rage-route'
addRoute('/somepage', 'Page Title', (state) => handlePageRoute(state))
addRedirect('/someotherpage', '/somepage')
addRoute('.*', 'Everything Else', (state) => handleDefaultRoute(state))
...
route('/somepage')
...
console.log(history.previous)
console.log(history.current)

API

Add route handler

addRoute(*path, *title, *callback)

Add redirect from a new path to an existing path

addRedirect(*newPath, *existingPath)

Route to another page, triggering callback set in addRoute

route(*path, *title, *state, *noStore)

Get array of registered routes

list()

We also expose a history object with the previous and current page

history

License

MIT © Andrew Carpenter

3.0.3

3 years ago

3.0.2

3 years ago

3.0.1

3 years ago

3.0.0

3 years ago

2.2.0

5 years ago

2.1.1

5 years ago

2.1.0

5 years ago

2.0.1

6 years ago

2.0.0

6 years ago

1.1.2

6 years ago

1.1.1

6 years ago

1.1.0

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago

0.9.4

7 years ago

0.9.3

7 years ago