Table of Contents

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

path string

URL path pattern for matching. Must not be null.

element ComponentNode

Component rendered when the route matches. Mutually exclusive with redirectTo.

scopeId string

Optional VContainer scope ID associated with this route.

loader Func<RouteLoaderContext, CancellationToken, UniTask<object>>

Async loader invoked on entry; result is exposed via Loader hook.

loaderMode LoaderMode

Whether the navigator awaits the loader (Await) or commits immediately and streams the result (Suspend).

errorElement ComponentNode

Component rendered when the loader throws.

children RouteDefinition[]

Nested child route definitions.

redirectTo string

Path to redirect to. Mutually exclusive with element and guard.

guard Func<RouteLoaderContext, string>

Pass-through guard returning a redirect path or null. Cannot be combined with redirectTo.

caseSensitive bool

When true, literal path segments match case-sensitively. Defaults to false (case-insensitive).

Returns

RouteDefinition

The created RouteDefinition.