Getting started

router5 is available in all major formats: ES6, CommonJS, and UMD.

It can be installed using npm or bower. Alternatively, you can download a specific version from github. Whether you install router5 from npm, bower or github, you will have access to the same files.


# bower
bower install router5
# npm
npm install router5

Include router5 in your application


// ES2015+
import Router5, { RouteNode, errorCodes, transitionPath, loggerPlugin } from 'router5';

import browserPlugin from 'router5/plugins/browser';
import listenersPlugin from 'router5/plugins/listeners';
import persistentParamsPlugin from 'router5/plugins/persistentParams';

// ES5
var router5 = require('router5');

var createRouter = router5.default;
var RouteNode = router5.RouteNode;
var errorCodes = router5.errorCodes;
var constants = router5.constants;
var transitionPath = router5.transitionPath;
var loggerPlugin = router5.loggerPlugin;

var browserPlugin = require('router5/plugins/browser');
var listenersPlugin = require('router5/plugins/listeners');
var persistentParamsPlugin = require('router5/plugins/persistentParams');


A UMD bundle is available in /dist/umd, and it should be used for AMD or globals. The bundle contains all router5 dependencies (route-node and path-parser), but doesn't contain plugins.

Plugins are packaged separately and available in /dist/umd: