Skip to main content

INavigationManager

Namespace: BlazorNative.Core

The navigation contract. Resolve it from DI and call it; the runtime supplies the implementation (NativeNavigationManager in BlazorNative.Runtime).

public interface INavigationManager

Attributes NullableContextAttribute

Remarks:

API-additions policy (consume-only contract). Same policy as IMobileBridge: this interface is a contract you call. Adding a member is declared non-breaking, because every supported consumer is a caller. Implementing it outside BlazorNative is unsupported — an addition will break an external implementer at compile time, in a minor version. Default (virtual) interface members were considered and rejected: the contracts package holds no bodies.

Location. This type lives in BlazorNative.Core and stays there. Moving it to a dedicated BlazorNative.Navigation package was declined (issue #23, closed not-planned on 2026-08-18) and is deferred past 1.0 as criterion S4 — not merely unscheduled. If it is ever wanted, it ships with a [TypeForwardedTo] from BlazorNative.Core, which makes the move non-breaking for both source and binary consumers, so nothing is lost by the wait.

See docs/plans/2026-07-21-phase-11.3-api-tiers.md (tier: STABLE).

Properties

CurrentRoute

The current route. Initialized at session start from the host's restored route when it maps to a known route; "/" otherwise.

string CurrentRoute { get; }

Property Value

String

Methods

Navigates to a registered route: notifies the host, swaps the root component (the old page's views are removed, the new page mounts fresh), then raises INavigationManager.RouteChanged. Completes synchronously on the inline-dispatcher runtimes. Throws ArgumentException for an unknown route (surfaced per the strict/error conventions).

ValueTask NavigateToAsync(string route)

Parameters

route String

Returns

ValueTask

Host-initiated back (Phase 5.1, M5 DoD #5): swaps to the previous route recorded by the last INavigationManager.NavigateToAsync(String) and returns true (handled). At the origin — no previous route (a fresh session, or the slot was consumed by an immediately preceding back) — returns false so the shell falls through to its default back behavior (Android finishes the Activity). A single previous-route slot: a back consumes it, so a second consecutive back returns false; a fresh forward navigation re-arms it.

ValueTask<bool> NavigateBackAsync()

Returns

ValueTask<Boolean>

Events

RouteChanged

Raised after a completed navigation with the new route. NOT raised for the initial mount (mounting is not a navigation).

event Action<string> RouteChanged;