@chialab/router
v3.0.2
Published
A simple agnostic router for Web Apps.
Downloads
129
Readme
Install
$ npm install @chialab/router
# or
$ yarn add @chialab/router
Use via cdn:
<script type="text/javascript" src="https://unpkg.com/@chialab/router-js"></script>
Example
import Router from '@chialab/router';
const appRouter = new Router();
appRouter.on('/user/:username', function(id) {
fetchUserById(id);
});
appRouter.on('/posts/:id', function(id) {
fetchPostById(id);
});
appRouter.on('/posts', function() {
listPosts();
});
appRouter.on('*', function() {
page404();
});
appRouter.start();
Development
Requirements
In order to build and test Router, the following requirements are needed:
Build the project
Install the dependencies and run the build
script:
$ yarn install
$ yarn build
This will generate the UMD and ESM bundles in the dist
folder, as well as the declaration file.
Test the project
Run the test
script:
$ yarn test
License
Router is released under the MIT license.