API Reference
Core API
createRouter
Create a router instance
routes
: your application routes, see defining routesoptions
: your router options, see router optionsdependencies
: the dependencies you want to make available in middleware and plugins, see dependency injection
cloneRouter
Clone an existing router.
router
: the router instance to clonedependencies
: the new dependencies, for the cloned router (optional)
add
Add routes, see defining routes
start
startPathOrState
: a starting path (string) or state (object). When usingbrowserPlugin
, this argument is optional: path will be read from the document locationdone
: a done callback (done(err, state)
)
isStarted
Check if the router is in a started state
navigate
Navigate to a new route
routeName
: the name of the route to navigate torouteParams
: the route paramsoptions
: options for the transition (replace
,reload
,skipTransition
,force
or any custom option)done
: a done callback (done(err, state)
)
navigateToDefault
Navigate to the default route (if any)
Stop
Stop your router
cancel
Cancel the current transition (if any)
forward
Set a route to forward to another route (when navigating to the first one)
getState
Return the current state
getOptions
Return current options
setOption
Set an option
setDependency
Set a dependency
setDependencies
Set dependencies
getDependencies
Return the current dependencies
useMiddleware
Register one or multiple middlewares, see middleware
clearMiddleware
Remove all middleware
usePlugin
Register one or multiple plugins, see plugins
canActivate
Set a canActivate
handler for the provided route name, see preventing navigation
canDeactivate
Set a canDeactivate
handler for the provided route name, see preventing navigation
clearCanDeactivate
Remove a canDeactivate
handler for the provided route name
buildPath
Build a path given a route name and params
matchPath
Attempt to match a path
setRootPath
Set the root path
isActive
Check if the provided route is currently active
name
: the route nameparams
: the route paramsstrictEquality
: whether to check if the given route is the active route, or a descendant of the active route (false
by default)ignoreQueryParams
: whether to ignore query params (true
by default)
areStateEqual
Compare two route state objects
areStatesDescendants
Check if a state is a descendant of another state
Browser plugin
See in the browser
The browser plugin adds the following to your router instance:
buildUrl
Build an URL
matchUrl
Match an URL
replaceHistoryState
Replace state in history and silently update your router instance state. Use if you know what you are doing.
Last updated