From version 4 and above of router5, this module is no longer needed and code has been moved to router5 main repo. Refer to http://router5.github.io/docs/migration-4.html for more details.
The dist
folder contains:
- AMD bundled (with minifed version) named
router5HistoryPlugin
- Browser module-less bundle (with minified version) adding to the globals
router5HistoryPlugin
- UMD and CommonJs files
Sources are distributed through:
- bower (
bower install router5-history
) - npm (
npm install --save router5-history
)
import { Router5 } from 'router5';
import historyPlugin from 'router5-history';
const router = new Router5()
.addNode('home', '/home')
.usePlugin(historyPlugin());
You can specify whether or not current active segments deactivation should be forced on popstate events. By default this is false
but I recommend setting it to true
to keep a clean history.
router.usePlugin(historyPlugin({ forceDeactivate: true }));
- Uses the history API to update history state and URL on router5 state changes
- Listens to popstate events (back and forward buttons, manual changes of URL)
Sometimes, you might want to silently replace the current history entry. This plugin decorates your router instance with a replaceHistoryState(name, params)
function. The new state provided will also replace the router last known state. Use with care, this could affect the next transition.
Please read contributing guidelines on router5 repository.