@chialab/router

3.0.2 • Public • Published

Router • A simple agnostic Router for Web Apps.

Documentation link Source link Authors link NPM License


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

Build status codecov

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.

Readme

Keywords

Package Sidebar

Install

npm i @chialab/router

Weekly Downloads

12

Version

3.0.2

License

MIT

Unpacked Size

296 kB

Total Files

28

Last publish

Collaborators

  • chialab-admin