Skip to content

API Reference

Enumerations

EnumerationDescription
ErrorTypesFlags so we can combine them when checking for multiple errors. This is the internal version of NavigationFailureType.
NavigationFailureTypeEnumeration with all possible types for navigation failures. Can be passed to isNavigationFailure to check for specific failures.

Interfaces

InterfaceDescription
_PathParserOptions-
_RouteLocationBaseBase properties for a normalized route location.
_RouteRecordBaseInternal type for common properties among all kind of RouteRecordRaw.
_RouterLinkITyped version of the RouterLink component. Its generic defaults to the typed router, so it can be inferred automatically for JSX.
HistoryStateAllowed HTML history.state
LocationAsRelativeRaw-
MatcherLocationNormalized/resolved Route location that returned by the matcher.
MatcherLocationAsPath-
NavigationFailureExtended Error that contains extra information regarding a failed navigation.
NavigationGuardNavigation Guard.
NavigationGuardNextnext() callback passed to navigation guards.
NavigationGuardWithThisNavigation Guard with a type parameter for this.
NavigationHookAfterNavigation hook triggered after a navigation is settled.
NavigationRedirectErrorInternal error used to detect a redirection.
RouteLocationAsPathGenericGeneric version of RouteLocationAsPath. It is used when no RouteMap is provided.
RouteLocationAsPathTypedHelper to generate a type safe version of the RouteLocationAsPath type.
RouteLocationAsRelativeGenericGeneric version of RouteLocationAsRelative. It is used when no RouteMap is provided.
RouteLocationAsRelativeTypedHelper to generate a type safe version of the RouteLocationAsRelative type.
RouteLocationGenericGeneric version of RouteLocation. It is used when no RouteMap is provided.
RouteLocationMatchedNormalized version of a route record.
RouteLocationNamedRawRoute Location that can infer the necessary params based on the name.
RouteLocationNormalizedGenericGeneric version of RouteLocationNormalized that is used when no RouteMap is provided.
RouteLocationNormalizedLoadedGenericGeneric version of RouteLocationNormalizedLoaded that is used when no RouteMap is provided.
RouteLocationNormalizedLoadedTypedHelper to generate a type safe version of the RouteLocationNormalizedLoaded type.
RouteLocationNormalizedTypedHelper to generate a type safe version of the RouteLocationNormalized type.
RouteLocationOptionsCommon options for all navigation methods.
RouteLocationPathRawRoute Location that can infer the possible paths.
RouteLocationResolvedGenericGeneric version of RouteLocationResolved. It is used when no RouteMap is provided.
RouteLocationResolvedTypedHelper to generate a type safe version of the RouteLocationResolved type.
RouteLocationTypedHelper to generate a type safe version of the RouteLocation type.
RouteMetaInterface to type meta fields in route records.
RouteQueryAndHash-
RouterRouter instance.
RouteRecordInfoHelper type to define a Typed RouteRecord
RouteRecordMultipleViewsRoute Record defining multiple named components with the components option.
RouteRecordMultipleViewsWithChildrenRoute Record defining multiple named components with the components option and children.
RouteRecordNormalizedNormalized version of a route record.
RouteRecordRedirectRoute Record that defines a redirect. Cannot have component or components as it is never rendered.
RouteRecordSingleViewRoute Record defining one single component with the component option.
RouteRecordSingleViewWithChildrenRoute Record defining one single component with a nested view. Differently from RouteRecordSingleView, this record has children and allows a redirect option.
RouterHistoryInterface implemented by History implementations that can be passed to the router as Router.history
RouterLinkProps-
RouterMatcherInternal RouterMatcher
RouterOptionsOptions to initialize a Router instance.
RouterScrollBehaviorType of the scrollBehavior option that can be passed to createRouter.
RouterViewProps-
TypesConfigAllows customizing existing types of the router that are used globally like $router, <RouterLink>, etc. ONLY FOR INTERNAL USAGE.
UseLinkOptionsOptions passed to useLink.
UseLinkReturnReturn type of useLink.

Type Aliases

Type AliasDescription
_AwaitableMaybe a promise maybe not
_RouteRecordProps-
LocationQueryNormalized query object that appears in RouteLocationNormalized
LocationQueryRawLoose LocationQuery object that can be passed to functions like Router.push and Router.replace or anywhere when creating a RouteLocationRaw
LocationQueryValuePossible values in normalized LocationQuery. null renders the query param but without an =.
LocationQueryValueRawPossible values when defining a query. undefined allows to remove a value.
NavigationGuardNextCallbackCallback that can be passed to next() in beforeRouteEnter() guards.
NavigationGuardReturnReturn types for a Navigation Guard. Based on TypesConfig
ParamValueUtility type for raw and non raw params like :id
ParamValueOneOrMoreUtility type for raw and non raw params like :id+
ParamValueZeroOrMoreUtility type for raw and non raw params like :id*
ParamValueZeroOrOneUtility type for raw and non raw params like :id?
PathParserOptions-
RouteComponentAllowed Component in RouteLocationMatched
RouteLocationRouteLocationRaw resolved using the matcher
RouteLocationAsPathRoute location as an object with a path property.
RouteLocationAsPathTypedListList of all possible RouteLocationAsPath indexed by the route name.
RouteLocationAsRelativeRoute location relative to the current location. It accepts other properties than path like params, query and hash to conveniently change them.
RouteLocationAsRelativeTypedListList of all possible RouteLocationAsRelative indexed by the route name.
RouteLocationAsStringSame as RouteLocationAsPath but as a string literal.
RouteLocationAsStringTypedHelper to generate a type safe version of the RouteLocationAsString type.
RouteLocationAsStringTypedListList of all possible RouteLocationAsString indexed by the route name.
RouteLocationNormalizedSimilar to RouteLocation but its `matched` property cannot contain redirect records
RouteLocationNormalizedLoadedSimilar to RouteLocationNormalized but its components do not contain any function to lazy load components. In other words, it's ready to be rendered by <RouterView>.
RouteLocationNormalizedLoadedTypedListList of all possible RouteLocationNormalizedLoaded indexed by the route name.
RouteLocationNormalizedTypedListList of all possible RouteLocationNormalized indexed by the route name.
RouteLocationRawRoute location that can be passed to router.push() and other user-facing APIs.
RouteLocationResolvedRoute location resolved with `router.resolve()`.
RouteLocationResolvedTypedListList of all possible RouteLocationResolved indexed by the route name.
RouteLocationTypedListList of all possible RouteLocation indexed by the route name.
RouteMapConvenience type to get the typed RouteMap or a generic one if not provided. It is extracted from the TypesConfig if it exists, it becomes RouteMapGeneric otherwise.
RouteMapGenericGeneric version of the RouteMap.
RouteParamsGenerate a type safe params for a route location. Requires the name of the route to be passed as a generic.
RouteParamsGeneric-
RouteParamsRawGenerate a type safe raw params for a route location. Requires the name of the route to be passed as a generic.
RouteParamsRawGeneric-
RouteParamValue-
RouteParamValueRaw-
RouteRecordNormalized version of a route record.
RouteRecordInfoGeneric-
RouteRecordNamePossible values for a route record after normalization
RouteRecordNameGenericGeneric version of RouteRecordName.
RouteRecordRaw-
RouteRecordRedirectOption-

Variables

VariableDescription
matchedRouteKeyRouteRecord being rendered by the closest ancestor Router View. Used for onBeforeRouteUpdate and onBeforeRouteLeave. rvlm stands for Router View Location Matched
routeLocationKeyAllows overriding the current route returned by useRoute in tests. rl stands for route location
routerKeyAllows overriding the router instance returned by useRouter in tests. r stands for router
RouterLinkComponent to render a link that triggers a navigation on click.
RouterViewComponent to display the current route the user is at.
routerViewLocationKeyAllows overriding the current route used by router-view. Internally this is used when the route prop is passed.
START_LOCATIONInitial route location where the router is. Can be used in navigation guards to differentiate the initial navigation.
viewDepthKeyAllows overriding the router view depth to control which component in matched is rendered. rvd stands for Router View Depth

Functions

FunctionDescription
createMemoryHistoryCreates an in-memory based history. The main purpose of this history is to handle SSR. It starts in a special location that is nowhere. It's up to the user to replace that location with the starter location by either calling router.push or router.replace.
createRouterCreates a Router instance that can be used by a Vue app.
createRouterMatcherCreates a Router Matcher.
createWebHashHistoryCreates a hash history. Useful for web applications with no host (e.g. file://) or when configuring a server to handle any URL is not possible.
createWebHistoryCreates an HTML5 history. Most common history for single page applications.
isNavigationFailureCheck if an object is a NavigationFailure.
loadRouteLocationEnsures a route is loaded, so it can be passed as o prop to <RouterView>.
onBeforeRouteLeaveAdd a navigation guard that triggers whenever the component for the current location is about to be left. Similar to beforeRouteLeave but can be used in any component. The guard is removed when the component is unmounted.
onBeforeRouteUpdateAdd a navigation guard that triggers whenever the current location is about to be updated. Similar to beforeRouteUpdate but can be used in any component. The guard is removed when the component is unmounted.
parseQueryTransforms a queryString into a LocationQuery object. Accept both, a version with the leading ? and without Should work as URLSearchParams
stringifyQueryStringifies a LocationQueryRaw object. Like URLSearchParams, it doesn't prepend a ?
useLinkReturns the internal behavior of a RouterLink without the rendering part.
useRouteReturns the current route location. Equivalent to using $route inside templates.
useRouterReturns the router instance. Equivalent to using $router inside templates.

Released under the MIT License.