Skip to content

vue-router / _RouterClassic

_RouterClassic ​

Router instance.

Extends ​

Properties ​

[APP_KEY] ​

ts
[APP_KEY]: App<unknown>;

Internal

The app instance that is used by the router.

Inherited from ​

ts
EXPERIMENTAL_Router_Base.[APP_KEY]

[DATA_LOADERS_EFFECT_SCOPE_KEY] ​

ts
[DATA_LOADERS_EFFECT_SCOPE_KEY]: EffectScope;

Internal

The effect scope used to run data loaders.

Inherited from ​

ts
EXPERIMENTAL_Router_Base.[DATA_LOADERS_EFFECT_SCOPE_KEY]

[INITIAL_DATA_KEY]? ​

ts
optional [INITIAL_DATA_KEY]?: false | Record<string, unknown>;

Internal

Used by defineLoader

Inherited from ​

ts
EXPERIMENTAL_Router_Base.[INITIAL_DATA_KEY]

[IS_SSR_KEY] ​

ts
[IS_SSR_KEY]: boolean;

Internal

Whether the router is running in server-side rendering mode.

Inherited from ​

ts
EXPERIMENTAL_Router_Base.[IS_SSR_KEY]

[LOADER_ENTRIES_KEY] ​

ts
[LOADER_ENTRIES_KEY]: _DefineLoaderEntryMap;

Internal

The entries used by data loaders. Put on the router for convenience.

Inherited from ​

ts
EXPERIMENTAL_Router_Base.[LOADER_ENTRIES_KEY]

[PENDING_LOCATION_KEY] ​

ts
[PENDING_LOCATION_KEY]: 
  | RouteLocationNormalizedLoadedGeneric
  | null;

Internal

Pending navigation that is waiting for data loaders to resolve.

Inherited from ​

ts
EXPERIMENTAL_Router_Base.[PENDING_LOCATION_KEY]

[SERVER_INITIAL_DATA_KEY]? ​

ts
optional [SERVER_INITIAL_DATA_KEY]?: false | Record<string, unknown>;

Internal

Gives access to the initial state during rendering. Should be set to false once it's consumed. Used by defineLoader

Inherited from ​

ts
EXPERIMENTAL_Router_Base.[SERVER_INITIAL_DATA_KEY]

currentRoute ​

ts
readonly currentRoute: ShallowRef<RouteLocationNormalizedLoadedGeneric>;

Current RouteLocationNormalized

Inherited from ​

ts
EXPERIMENTAL_Router_Base.currentRoute

listening ​

ts
listening: boolean;

Allows turning off the listening of history events. This is a low level api for micro-frontend.

Inherited from ​

ts
EXPERIMENTAL_Router_Base.listening

options ​

ts
readonly options: RouterOptions;

Original options object passed to create the Router

Methods ​

addRoute() ​

Call Signature ​

ts
addRoute(parentName, route): () => void;

Add a new route record as the child of an existing route.

Parameters ​
parentName ​

NonNullable<RouteRecordNameGeneric>

Parent Route Record where route should be appended at

route ​

RouteRecordRaw

Route Record to add

Returns ​

() => void

Call Signature ​

ts
addRoute(route): () => void;

Add a new route record to the router.

Parameters ​
route ​

RouteRecordRaw

Route Record to add

Returns ​

() => void


afterEach() ​

ts
afterEach(guard): () => void;

Add a navigation hook that is executed after every navigation. Returns a function that removes the registered hook.

Parameters ​

guard ​

NavigationHookAfter

navigation hook to add

Returns ​

a function that removes the registered hook

() => void

Example ​

js
router.afterEach((to, from, failure) => {
  if (isNavigationFailure(failure)) {
    console.log('failed navigation', failure)
  }
})

Inherited from ​

ts
EXPERIMENTAL_Router_Base.afterEach

back() ​

ts
back(): void;

Go back in history if possible by calling history.back(). Equivalent to router.go(-1).

Returns ​

void

Inherited from ​

ts
EXPERIMENTAL_Router_Base.back

beforeEach() ​

ts
beforeEach(guard): () => void;

Add a navigation guard that executes before any navigation. Returns a function that removes the registered guard.

Parameters ​

guard ​

NavigationGuardWithThis<undefined>

navigation guard to add

Returns ​

() => void

Inherited from ​

ts
EXPERIMENTAL_Router_Base.beforeEach

beforeResolve() ​

ts
beforeResolve(guard): () => void;

Add a navigation guard that executes before navigation is about to be resolved. At this state all component have been fetched and other navigation guards have been successful. Returns a function that removes the registered guard.

Parameters ​

guard ​

_NavigationGuardResolved

navigation guard to add

Returns ​

a function that removes the registered guard

() => void

Example ​

js
router.beforeResolve(to => {
  if (to.meta.requiresAuth && !isAuthenticated) return false
})

Inherited from ​

ts
EXPERIMENTAL_Router_Base.beforeResolve

clearRoutes() ​

ts
clearRoutes(): void;

Delete all routes from the router.

Returns ​

void


forward() ​

ts
forward(): void;

Go forward in history if possible by calling history.forward(). Equivalent to router.go(1).

Returns ​

void

Inherited from ​

ts
EXPERIMENTAL_Router_Base.forward

getRoutes() ​

ts
getRoutes(): RouteRecordNormalized[];

Get a full list of all the route records.

Returns ​

RouteRecordNormalized[]

Inherited from ​

ts
EXPERIMENTAL_Router_Base.getRoutes

go() ​

ts
go(delta): void;

Allows you to move forward or backward through the history. Calls history.go().

Parameters ​

delta ​

number

The position in the history to which you want to move, relative to the current page

Returns ​

void

Inherited from ​

ts
EXPERIMENTAL_Router_Base.go

hasRoute() ​

ts
hasRoute(name): boolean;

Checks if a route with a given name exists

Parameters ​

name ​

NonNullable<RouteRecordNameGeneric>

Name of the route to check

Returns ​

boolean

Inherited from ​

ts
EXPERIMENTAL_Router_Base.hasRoute

install() ​

ts
install(app): void;

Internal

Called automatically by app.use(router). Should not be called manually by the user. This will trigger the initial navigation when on client side.

Parameters ​

app ​

App

Application that uses the router

Returns ​

void

Inherited from ​

ts
EXPERIMENTAL_Router_Base.install

isReady() ​

ts
isReady(): Promise<void>;

Returns a Promise that resolves when the router has completed the initial navigation, which means it has resolved all async enter hooks and async components that are associated with the initial route. If the initial navigation already happened, the promise resolves immediately.

This is useful in server-side rendering to ensure consistent output on both the server and the client. Note that on server side, you need to manually push the initial location while on client side, the router automatically picks it up from the URL.

Returns ​

Promise<void>

Inherited from ​

ts
EXPERIMENTAL_Router_Base.isReady

onError() ​

ts
onError(handler): () => void;

Adds an error handler that is called every time a non caught error happens during navigation. This includes errors thrown synchronously and asynchronously, errors returned or passed to next in any navigation guard, and errors occurred when trying to resolve an async component that is required to render a route.

Parameters ​

handler ​

_ErrorListener

error handler to register

Returns ​

() => void

Inherited from ​

ts
EXPERIMENTAL_Router_Base.onError

push() ​

ts
push(to): Promise<void | NavigationFailure | undefined>;

Programmatically navigate to a new URL by pushing an entry in the history stack.

Parameters ​

to ​

| string | RouteLocationAsRelativeGeneric | RouteLocationAsPathGeneric

Route location to navigate to

Returns ​

Promise<void | NavigationFailure | undefined>

Inherited from ​

ts
EXPERIMENTAL_Router_Base.push

removeRoute() ​

ts
removeRoute(name): void;

Remove an existing route by its name.

Parameters ​

name ​

NonNullable<RouteRecordNameGeneric>

Name of the route to remove

Returns ​

void


replace() ​

ts
replace(to): Promise<void | NavigationFailure | undefined>;

Programmatically navigate to a new URL by replacing the current entry in the history stack.

Parameters ​

to ​

| string | RouteLocationAsRelativeGeneric | RouteLocationAsPathGeneric

Route location to navigate to

Returns ​

Promise<void | NavigationFailure | undefined>

Inherited from ​

ts
EXPERIMENTAL_Router_Base.replace

resolve() ​

Call Signature ​

ts
resolve<Name>(to, currentLocation?): RouteLocationResolvedGeneric;

Returns the normalized version of a route location. Also includes an href property that includes any existing base. By default, the currentLocation used is router.currentRoute and should only be overridden in advanced use cases.

Type Parameters ​
Name ​

Name extends string | symbol = string | symbol

Parameters ​
to ​

RouteLocationAsRelativeTyped<RouteMapGeneric, Name>

Raw route location to resolve

currentLocation? ​

RouteLocationNormalizedLoadedGeneric

Optional current location to resolve against

Returns ​

RouteLocationResolvedGeneric

Inherited from ​
ts
EXPERIMENTAL_Router_Base.resolve

Call Signature ​

ts
resolve(to, currentLocation?): RouteLocationResolvedGeneric;
Parameters ​
to ​

| string | RouteLocationAsRelativeGeneric | RouteLocationAsPathGeneric

currentLocation? ​

RouteLocationNormalizedLoadedGeneric

Returns ​

RouteLocationResolvedGeneric

Inherited from ​
ts
EXPERIMENTAL_Router_Base.resolve

Released under the MIT License.