API Reference
Enumerations
Enumeration | Description |
---|---|
ErrorTypes | Flags so we can combine them when checking for multiple errors. This is the internal version of NavigationFailureType. |
NavigationFailureType | Enumeration with all possible types for navigation failures. Can be passed to isNavigationFailure to check for specific failures. |
Interfaces
Interface | Description |
---|---|
_PathParserOptions | - |
_RouteLocationBase | Base properties for a normalized route location. |
_RouteRecordBase | Internal type for common properties among all kind of RouteRecordRaw. |
_RouterLinkI | Typed version of the RouterLink component. Its generic defaults to the typed router, so it can be inferred automatically for JSX. |
HistoryState | Allowed HTML history.state |
LocationAsRelativeRaw | - |
MatcherLocation | Normalized/resolved Route location that returned by the matcher. |
MatcherLocationAsPath | - |
NavigationFailure | Extended Error that contains extra information regarding a failed navigation. |
NavigationGuard | Navigation Guard. |
NavigationGuardNext | next() callback passed to navigation guards. |
NavigationGuardWithThis | Navigation Guard with a type parameter for this . |
NavigationHookAfter | Navigation hook triggered after a navigation is settled. |
NavigationRedirectError | Internal error used to detect a redirection. |
RouteLocationAsPathGeneric | Generic version of RouteLocationAsPath. It is used when no RouteMap is provided. |
RouteLocationAsPathTyped | Helper to generate a type safe version of the RouteLocationAsPath type. |
RouteLocationAsRelativeGeneric | Generic version of RouteLocationAsRelative. It is used when no RouteMap is provided. |
RouteLocationAsRelativeTyped | Helper to generate a type safe version of the RouteLocationAsRelative type. |
RouteLocationGeneric | Generic version of RouteLocation. It is used when no RouteMap is provided. |
RouteLocationMatched | Normalized version of a route record. |
RouteLocationNamedRaw | Route Location that can infer the necessary params based on the name. |
RouteLocationNormalizedGeneric | Generic version of RouteLocationNormalized that is used when no RouteMap is provided. |
RouteLocationNormalizedLoadedGeneric | Generic version of RouteLocationNormalizedLoaded that is used when no RouteMap is provided. |
RouteLocationNormalizedLoadedTyped | Helper to generate a type safe version of the RouteLocationNormalizedLoaded type. |
RouteLocationNormalizedTyped | Helper to generate a type safe version of the RouteLocationNormalized type. |
RouteLocationOptions | Common options for all navigation methods. |
RouteLocationPathRaw | Route Location that can infer the possible paths. |
RouteLocationResolvedGeneric | Generic version of RouteLocationResolved. It is used when no RouteMap is provided. |
RouteLocationResolvedTyped | Helper to generate a type safe version of the RouteLocationResolved type. |
RouteLocationTyped | Helper to generate a type safe version of the RouteLocation type. |
RouteMeta | Interface to type meta fields in route records. |
RouteQueryAndHash | - |
Router | Router instance. |
RouteRecordInfo | Helper type to define a Typed RouteRecord |
RouteRecordMultipleViews | Route Record defining multiple named components with the components option. |
RouteRecordMultipleViewsWithChildren | Route Record defining multiple named components with the components option and children. |
RouteRecordNormalized | Normalized version of a route record. |
RouteRecordRedirect | Route Record that defines a redirect. Cannot have component or components as it is never rendered. |
RouteRecordSingleView | Route Record defining one single component with the component option. |
RouteRecordSingleViewWithChildren | Route Record defining one single component with a nested view. Differently from RouteRecordSingleView, this record has children and allows a redirect option. |
RouterHistory | Interface implemented by History implementations that can be passed to the router as Router.history |
RouterLinkProps | - |
RouterMatcher | Internal RouterMatcher |
RouterOptions | Options to initialize a Router instance. |
RouterScrollBehavior | Type of the scrollBehavior option that can be passed to createRouter . |
RouterViewProps | - |
TypesConfig | Allows customizing existing types of the router that are used globally like $router , <RouterLink> , etc. ONLY FOR INTERNAL USAGE. |
UseLinkOptions | Options passed to useLink. |
UseLinkReturn | Return type of useLink. |
Type Aliases
Type Alias | Description |
---|---|
_Awaitable | Maybe a promise maybe not |
_RouteRecordProps | - |
LocationQuery | Normalized query object that appears in RouteLocationNormalized |
LocationQueryRaw | Loose LocationQuery object that can be passed to functions like Router.push and Router.replace or anywhere when creating a RouteLocationRaw |
LocationQueryValue | Possible values in normalized LocationQuery. null renders the query param but without an = . |
LocationQueryValueRaw | Possible values when defining a query. undefined allows to remove a value. |
NavigationGuardNextCallback | Callback that can be passed to next() in beforeRouteEnter() guards. |
NavigationGuardReturn | Return types for a Navigation Guard. Based on TypesConfig |
ParamValue | Utility type for raw and non raw params like :id |
ParamValueOneOrMore | Utility type for raw and non raw params like :id+ |
ParamValueZeroOrMore | Utility type for raw and non raw params like :id* |
ParamValueZeroOrOne | Utility type for raw and non raw params like :id? |
PathParserOptions | - |
RouteComponent | Allowed Component in RouteLocationMatched |
RouteLocation | RouteLocationRaw resolved using the matcher |
RouteLocationAsPath | Route location as an object with a path property. |
RouteLocationAsPathTypedList | List of all possible RouteLocationAsPath indexed by the route name. |
RouteLocationAsRelative | Route location relative to the current location. It accepts other properties than path like params , query and hash to conveniently change them. |
RouteLocationAsRelativeTypedList | List of all possible RouteLocationAsRelative indexed by the route name. |
RouteLocationAsString | Same as RouteLocationAsPath but as a string literal. |
RouteLocationAsStringTyped | Helper to generate a type safe version of the RouteLocationAsString type. |
RouteLocationAsStringTypedList | List of all possible RouteLocationAsString indexed by the route name. |
RouteLocationNormalized | Similar to RouteLocation but its `matched` property cannot contain redirect records |
RouteLocationNormalizedLoaded | Similar 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> . |
RouteLocationNormalizedLoadedTypedList | List of all possible RouteLocationNormalizedLoaded indexed by the route name. |
RouteLocationNormalizedTypedList | List of all possible RouteLocationNormalized indexed by the route name. |
RouteLocationRaw | Route location that can be passed to router.push() and other user-facing APIs. |
RouteLocationResolved | Route location resolved with `router.resolve()`. |
RouteLocationResolvedTypedList | List of all possible RouteLocationResolved indexed by the route name. |
RouteLocationTypedList | List of all possible RouteLocation indexed by the route name. |
RouteMap | Convenience 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. |
RouteMapGeneric | Generic version of the RouteMap . |
RouteParams | Generate a type safe params for a route location. Requires the name of the route to be passed as a generic. |
RouteParamsGeneric | - |
RouteParamsRaw | Generate a type safe raw params for a route location. Requires the name of the route to be passed as a generic. |
RouteParamsRawGeneric | - |
RouteParamValue | - |
RouteParamValueRaw | - |
RouteRecord | Normalized version of a route record. |
RouteRecordInfoGeneric | - |
RouteRecordName | Possible values for a route record after normalization |
RouteRecordNameGeneric | Generic version of RouteRecordName. |
RouteRecordRaw | - |
RouteRecordRedirectOption | - |
Variables
Variable | Description |
---|---|
matchedRouteKey | RouteRecord being rendered by the closest ancestor Router View. Used for onBeforeRouteUpdate and onBeforeRouteLeave . rvlm stands for Router View Location Matched |
routeLocationKey | Allows overriding the current route returned by useRoute in tests. rl stands for route location |
routerKey | Allows overriding the router instance returned by useRouter in tests. r stands for router |
RouterLink | Component to render a link that triggers a navigation on click. |
RouterView | Component to display the current route the user is at. |
routerViewLocationKey | Allows overriding the current route used by router-view. Internally this is used when the route prop is passed. |
START_LOCATION | Initial route location where the router is. Can be used in navigation guards to differentiate the initial navigation. |
viewDepthKey | Allows overriding the router view depth to control which component in matched is rendered. rvd stands for Router View Depth |
Functions
Function | Description |
---|---|
createMemoryHistory | Creates 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 . |
createRouter | Creates a Router instance that can be used by a Vue app. |
createRouterMatcher | Creates a Router Matcher. |
createWebHashHistory | Creates 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. |
createWebHistory | Creates an HTML5 history. Most common history for single page applications. |
isNavigationFailure | Check if an object is a NavigationFailure. |
loadRouteLocation | Ensures a route is loaded, so it can be passed as o prop to <RouterView> . |
onBeforeRouteLeave | Add 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. |
onBeforeRouteUpdate | Add 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. |
parseQuery | Transforms a queryString into a LocationQuery object. Accept both, a version with the leading ? and without Should work as URLSearchParams |
stringifyQuery | Stringifies a LocationQueryRaw object. Like URLSearchParams , it doesn't prepend a ? |
useLink | Returns the internal behavior of a RouterLink without the rendering part. |
useRoute | Returns the current route location. Equivalent to using $route inside templates. |
useRouter | Returns the router instance. Equivalent to using $router inside templates. |