Skip to content
/ router Public
forked from kevindurb/router

A simple js router designed to solve one problem outside of any other frameworks like React, Angular, or Vue

Notifications You must be signed in to change notification settings

hanford/router

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

npm (scoped)

router

A simple js router designed to solve one problem outside of any other frameworks like React, Angular, or Vue

Installing

npm install --save @kevindurb/router

Usage

import { router } from '@kevindurb/router';

const app = router();

app.add('/people', () => {
  console.log('showing people!');
});

app.add('/people/:id', ({ id }) => {
  console.log('load person with id: ', id);
});

app.exec('/people/256'); // load person with id: 256
app.exec('/people'); // showing people!

Usage with history package

npm install --save history
import createHistory from 'history/createBrowserHistory';
import { router, mountHistory } from '@kevindurb/router';

const history = createHistory();
const app = router();

app.add('/people', () => {
  console.log('showing people!');
});

app.add('/people/:id', ({ id }) => {
  console.log('load person with id: ', id);
});

history.listen(mountHistory(app));

history.push('/people/65'); // load person with id: 65

About

A simple js router designed to solve one problem outside of any other frameworks like React, Angular, or Vue

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 100.0%