A route that can be navigated to.

const routes: Route[] = [
{
component: Home
},
{
path: "(?<child>.*)",
component: ParseRouteParams
}
]

Constructors

  • The constructor for the Route class.

    Parameters

    • config: RouteConfig

      An instance of the Route class.

    Returns Route

Properties

basePath?: string

The base path of the route.

This is useful if you want to be declarative about the base path of the route and not depend on the router to determine the base path.

children?: Route[]

The children routes of the route.

This is useful if you want to be declarative about the routes that are direct children of this route and not depend on the router to determine the children when there are multiple instances.

If no value is provided, there are no direct child routes. Routes may be mapped to children routes by the router when there are multiple instances with overlapping basePath values.

const routes: Route[] = [
...
{
path: "/users",
children: [
{
path: "/:id",
component: User
}
]
}
...
]
component?: any

The component to render when the route is active.

If no value is provided, the route will not render a component. This is useful if you want to use pre or post hooks to render a component or snippet conditionally.

hooks?: { post?: Hook | Hook[]; pre?: Hook | Hook[] }

Hooks to be run before and after the routes are rendered at the router level (independent of the route hooks if applicable).

If no value is provided, no hooks will be run.

name?: string | number

The unique identifier of this route. This is useful if you need to track routes outside of the router's scope.

If no value is provided, the route will not have a name.

path?: PathType

The path of the route to match against the current path.

If not provided, the route will match any path as it will be the default route.

props?: Record<string, any>

The props to pass to the component.

If a value is provided, the component will receive this value in $props().

querystring?: Query

The query params of the route.

If no value is provided, there are no query params.

status?: number

The status of the route once it has been matched or otherwise processed.

traces?: Trace[] = ...

Traces are a list of objects that describe the route's path and query params as it is processed by the router.

Methods

  • The absolute path of the route by combining the router's base path and the route's path.

    Returns string

  • Parse the route against the given path.

    Parameters

    • path: PathType

      The path to parse against the route.

    Returns Evaluation