Method Route
- Namespace
- Velvet
- Assembly
- Velvet.Docs.dll
Route(string?, ComponentNode?, string?, Func<RouteLoaderContext, CancellationToken, VelvetTask<object>>?, LoaderMode, ComponentNode?, RouteDefinition[]?, string?, Func<RouteLoaderContext, string>?, bool, Func<RouteActionContext, CancellationToken, VelvetTask<object>>?, string?, object?)
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, VelvetTask<object>>? loader = null, LoaderMode loaderMode = LoaderMode.Await, ComponentNode? errorElement = null, RouteDefinition[]? children = null, string? redirectTo = null, Func<RouteLoaderContext, string>? guard = null, bool caseSensitive = false, Func<RouteActionContext, CancellationToken, VelvetTask<object>>? action = null, string? id = null, object? handle = null)
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, VelvetTask<object>>Async loader invoked on entry; result is exposed via Loader hook.
loaderModeLoaderModeWhether the navigation waits for the loader before committing (Await) or commits immediately and streams the result in (Suspend). See LoaderMode.
errorElementComponentNodeComponent rendered in place of
elementwhen this route's loader fails, or a descendant route's does with no nearer errorElement.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).
actionFunc<RouteActionContext, CancellationToken, VelvetTask<object>>Called for a submission other than
getthat targets this route; its result is exposed viaHooks.UseActionData.idstringIdentifies the route among the matches; see Id.
handleobjectData the route carries for
Hooks.UseMatches; see Handle.
Returns
- RouteDefinition
The created RouteDefinition.
Exceptions
- ArgumentOutOfRangeException
loaderModenames no member of LoaderMode.