Migrating from 0.x to 1.x
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

1
# yarn
2
yarn add router5
3
# npm
4
npm install router5
Copied!

Include router5 in your application

CommonJS
1
// ES2015+
2
import createRouter, { RouteNode, errorCodes, transitionPath, loggerPlugin, constants } from 'router5';
3
4
import browserPlugin from 'router5-plugin-browser';
5
import listenersPlugin from 'router5-plugin-listeners';
6
import persistentParamsPlugin from 'router5-plugin-persistent-params';
7
8
// ES5
9
var router5 = require('router5');
10
11
var createRouter = router5.default;
12
var RouteNode = router5.RouteNode;
13
var errorCodes = router5.errorCodes;
14
var constants = router5.constants;
15
var transitionPath = router5.transitionPath;
16
var loggerPlugin = router5.loggerPlugin;
17
var constants = router5.constants;
18
19
var browserPlugin = require('router5-plugin-browser');
20
var listenersPlugin = require('router5-plugin-listeners');
21
var persistentParamsPlugin = require('router5-plugin-persistent-params');
Copied!
UMD
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:
  • browserPlugin UMD module is named router5BrowserPlugin
  • listenersPlugin UMD module is named router5ListenersPlugin
  • persistentParamsPlugin UMD module is named router5PersistentParamsPlugin
    bundle is named router5ListenersPlugin.