Method Route
- Namespace
- Velvet
- Assembly
- Velvet.Docs.dll
Route(string?, ComponentNode?, string?, Func<RouteLoaderContext, CancellationToken, UniTask<object>>?, LoaderMode, ComponentNode?, RouteDefinition[]?, string?, Func<RouteLoaderContext, string>?, bool)
Path-based route definition. Declaratively expresses Velvet Router's nested routes and Loaders.
public static RouteDefinition Route(string? path, ComponentNode? element = null, string? scopeId = null, Func<RouteLoaderContext, CancellationToken, UniTask<object>>? loader = null, LoaderMode loaderMode = LoaderMode.Await, ComponentNode? errorElement = null, RouteDefinition[]? children = null, string? redirectTo = null, Func<RouteLoaderContext, string>? guard = null, bool caseSensitive = false)
Parameters
pathstringURL path pattern for matching. Must not be null.
elementComponentNodeComponent rendered when the route matches. Mutually exclusive with
redirectTo.scopeIdstringOptional VContainer scope ID associated with this route.
loaderFunc<RouteLoaderContext, CancellationToken, UniTask<object>>Async loader invoked on entry; result is exposed via Loader hook.
loaderModeLoaderModeWhether the navigator awaits the loader (Await) or commits immediately and streams the result (Suspend).
errorElementComponentNodeComponent rendered when the loader throws.
childrenRouteDefinition[]Nested child route definitions.
redirectTostringPath to redirect to. Mutually exclusive with
elementandguard.guardFunc<RouteLoaderContext, string>Pass-through guard returning a redirect path or null. Cannot be combined with
redirectTo.caseSensitiveboolWhen true, literal path segments match case-sensitively. Defaults to false (case-insensitive).
Returns
- RouteDefinition
The created RouteDefinition.