Skip to main content

Route

Defines a single route in the route tree.

Routes can be nested via children to create layout hierarchies. A route with component and children acts as a layout route — its component should call use_route_outlet to render the matched child.

Parameters:

  • path (str | None, default: None) - Relative path segment. Supports dynamic segments (:name), optional segments (:name?), splats (:name*), and custom regex constraints (:name(\\d+)). None for pathless layout routes.
  • index (bool, default: False) - When True, this route matches when the parent path matches exactly (no further segments). Index routes must not have path or children.
  • component (Callable | None, default: None) - A @component function to render when this route matches.
  • children (list[Route] | None, default: None) - Nested child routes.
  • loader (Callable[..., Any] | None, default: None) - Optional data loader function. Called with the matched params dict when the route matches. Result is available via use_route_loader_data.
  • outlet (bool, default: False) - When True and manage_views=True, this route acts as a layout that wraps its matched child via use_route_outlet within a single View, instead of each child becoming a separate View.

Properties

childrenclass-attributeinstance-attribute

children: list[Route] | None = field(default=None)

componentclass-attributeinstance-attribute

component: Callable | None = None

indexclass-attributeinstance-attribute

index: bool = False

loaderclass-attributeinstance-attribute

loader: Callable[..., Any] | None = None

outletclass-attributeinstance-attribute

outlet: bool = False

pathclass-attributeinstance-attribute

path: str | None = None