Skip to content

The runtime module boots the router and drives navigation from your host application.

RouterProvider installs the router into your app. The README bootstrap shows the canonical construction:

use navi_router::{Location, NotFoundMode, RouterOptions, RouterProvider};
let tree = route_tree::build_route_tree();
let router = RouterProvider::new_with_options(
window_id,
window_handle,
Location::new("/"),
tree,
RouterOptions {
not_found_mode: NotFoundMode::Fuzzy,
..Default::default()
},
cx,
);
route_tree::register_routes(cx);

A RouterHandle is the shared handle to the running router state; hooks and Navigator read and drive it.

Field Type Description
default_pending_ms u64 Default pending-navigation timeout in milliseconds.
default_pending_min_ms u64 Minimum time a pending state is shown, avoiding flicker.
not_found_mode NotFoundMode How unmatched URLs resolve to the not-found UI.
Variant Behavior
Root Unmatched navigations resolve against the root not-found route.
Fuzzy Unmatched navigations fall back fuzzily to the closest match.

Navigator is the programmatic navigation API. use_navigate!() returns a fresh one; from_route(base), from_handle(handle), and from_handle_route(handle, base) construct it scoped to a base path.

Method Description
push(path) / push_location(loc) Navigate, adding a history entry.
push_location_with(loc, options) Navigate with NavigateOptions.
replace(path) / replace_location(loc) Navigate, overwriting the current entry.
replace_location_with(loc, options) Replace with NavigateOptions.
transact(ops) Apply a batch of NavOps atomically with a single re-render.
back() / forward() Step one entry back or forward.
go(delta) Relative traversal, clamped to the valid range.
can_go_back() / can_go_forward() Associated functions — query history bounds.
preload(path) Warm the loader cache for a path.
handle() Access the underlying RouterHandle.
Field Type Description
replace bool Replace instead of push.
reset_scroll Option<bool> Force the target scroll to the top.
hash_scroll_into_view Option<ScrollIntoViewOptions> Scroll behavior for hash navigations.
view_transition Option<ViewTransitionOptions> View transition preferences.
ignore_blocker bool Bypass registered navigation blockers.
reload_document bool Force a document reload semantics.
href Option<String> Explicit href override.

Navigator::transact takes any iterator of NavOp — Push(Location), Replace(Location), Back, Forward, Go(isize) — and applies them as one atomic navigation with a single re-render.