[]previous and next page

RouteDefinition

A route built with defineRoute.

A route built with defineRoute. Its typed helpers read the route's own params, search and loader data without a from argument.

Import#

ts
import type { RouteDefinition } from "@shadow-js/router";

Signature#

ts
interface RouteDefinition<P extends string = string, L = unknown, S = unknown> {
  /** The route id (the path unless the options set one). */
  readonly id: string;
  /** The route path, relative to the parent. */
  readonly path: P;
  /** Internal: the erased options the router reads. */
  readonly spec: RouteSpec;
  /** Typed params of this route, reactive. */
  readonly useParams: () => ParamsView<P>;
  /** Typed validated search of this route, reactive. */
  readonly useSearch: () => S;
  /** Accessor of this route's loader data. */
  readonly useLoaderData: () => () => L | undefined;
}

Members#

Name Type Description
P P extends string = string
L L = unknown
S S = unknown
id readonly id: string The route id (the path unless the options set one).
path readonly path: P The route path, relative to the parent.
spec readonly spec: RouteSpec Internal: the erased options the router reads.
useParams readonly useParams: () => ParamsView<P> Typed params of this route, reactive.
useSearch readonly useSearch: () => S Typed validated search of this route, reactive.
useLoaderData readonly useLoaderData: () => () => L | undefined Accessor of this route's loader data.