Getting Started

Last updated 5 months ago

router5 is available in all major formats: ES6, CommonJS, and UMD. It can be installed using npm or yarn. Alternatively, you can download a specific version from github.

Installation

# yarn
yarn add router5
# npm
npm install router5

Include router5 in your application

ES2015 syntax

// ES2015+
import createRouter from 'router5';
‚Äč
import browserPlugin from 'router5/plugins/browser';
import persistentParamsPlugin from 'router5/plugins/persistentParams';

CommonJS syntax

var createRouter = require('router5').default;
var browserPlugin = require('router5/plugins/browser');
var persistentParamsPlugin = require('router5/plugins/persistentParams');

UMD

Various UMD bundles are accessible under /dist/umd: you should use them for AMD or global. The router5 bundle contains all router5 dependencies (route-node and path-parser), but doesn't contain plugins.