Migrating from 1.x to 2.x
New features
You can now pass to
router.add()
objects containingcanActivate
functions and those functions will be registered. No need to call for each routeaddNode
orcanActivate
.Persistent parameters plugin now available.
Breaking change
router.registerComponent
androuter.deregisterComponent
have been removed in favour ofcanDeactivate
Additional arguments now apply to middleware functions.
Context has been removed from middleware functions.
Middleware functions are now a function taking a router instance and returning a function called on each transition.
Plugins, like middleware functions, are now a function taking a router instance and returning an object of methods (which doesn't contain an
init
function anymore).autoCleanUp
is no longer shared with router5-listeners. If you need to turn off automatic deregistration of node listeners, pass{ autoCleanUp: false }
to the listeners plugin.router5
package now exportsRouter5
as default, andRouteNode
,loggerPlugin
,errCodes
andtransitionPath
as named exports
Code example
ES2015+
ES5
Last updated