Interface Route<R, C>

Defines a single route.

A route represents a single or multiple sections in the URL. It defines the behavior of a page in response to URL updates. A route can act as a content producer or as middleware for child routes.

interface Route<R, C> {
    action?(this: Route<R, C>, context: RouteContext<R, C>, commands: Commands): MaybePromise<ActionResult | RouteContext<R, C>>;
    animate?: boolean | Readonly<{
        enter?: string;
        leave?: string;
    }>;
    children?:
        | readonly Route<ActionValue, RouteExtension<R, C>, ContextExtension<R, C>>[] & ChildrenCallback<R, C>
        | readonly Route<ActionValue, RouteExtension<R, C>, ContextExtension<R, C>>[] & readonly Route<R, C>[]
        | ChildrenCallback<ActionValue, RouteExtension<R, C>, ContextExtension<R, C>> & ChildrenCallback<R, C>
        | ChildrenCallback<ActionValue, RouteExtension<R, C>, ContextExtension<R, C>> & readonly Route<R, C>[];
    component?: string;
    fullPath?: string;
    name?: string;
    parent?: Route<ActionValue, RouteExtension<R, C>, ContextExtension<R, C>>;
    path: string;
    redirect?: string;
}

Type Parameters

  • R extends object = EmptyObject

    The type of the result produced by the route.

  • C extends object = EmptyObject

    The type of additional route-specific data. Defaults to an empty object.

Properties

animate?: boolean | Readonly<{
    enter?: string;
    leave?: string;
}>
children?:
    | readonly Route<ActionValue, RouteExtension<R, C>, ContextExtension<R, C>>[] & ChildrenCallback<R, C>
    | readonly Route<ActionValue, RouteExtension<R, C>, ContextExtension<R, C>>[] & readonly Route<R, C>[]
    | ChildrenCallback<ActionValue, RouteExtension<R, C>, ContextExtension<R, C>> & ChildrenCallback<R, C>
    | ChildrenCallback<ActionValue, RouteExtension<R, C>, ContextExtension<R, C>> & readonly Route<R, C>[]
component?: string
fullPath?: string
name?: string

The name of the route.

parent?: Route<ActionValue, RouteExtension<R, C>, ContextExtension<R, C>>
path: string

The path pattern that the route matches.

redirect?: string

Methods

  • An action that is executed when the route is resolved.

    Actions are executed recursively from the root route to the child route and can either produce content or perform actions before or after the child's action.

    Parameters

    Returns MaybePromise<ActionResult | RouteContext<R, C>>

    The result of the route resolution. It could be either a value produced by the action or a new context to continue the resolution process.