pub struct Router { /* private fields */ }Expand description
A router instance. Clone to share across closures.
Not a global singleton — create one per navigation scope. Pass it through your UI builder or store it in context state.
Implementations§
Source§impl Router
impl Router
pub fn can_go_back(&self) -> bool
pub fn can_go_forward(&self) -> bool
Sourcepub fn current_path(&self) -> String
pub fn current_path(&self) -> String
Get the current path
Sourcepub fn current_route(&self) -> Option<MatchedRoute>
pub fn current_route(&self) -> Option<MatchedRoute>
Get the current matched route
Sourcepub fn params(&self) -> RouteParams
pub fn params(&self) -> RouteParams
Get current route parameters
Sourcepub fn query(&self) -> QueryParams
pub fn query(&self) -> QueryParams
Get current query parameters
Sourcepub fn push_named(&self, name: &str, params: &[(&str, &str)])
pub fn push_named(&self, name: &str, params: &[(&str, &str)])
Navigate to a named route with parameters
Sourcepub fn handle_deep_link(&self, uri: &str)
pub fn handle_deep_link(&self, uri: &str)
Handle a deep link URI from the platform.
Parses the URI and navigates to the extracted path. Call this from the platform runner when receiving a deep link.
Sourcepub fn register_back_handler(&self) -> BackHandlerHandle
pub fn register_back_handler(&self) -> BackHandlerHandle
Register this router as the handler for the system back button.
When back is pressed and the router can go back, it navigates back and consumes the event. Otherwise, the event propagates (app exit).
Sourcepub fn outlet(&self) -> Div
pub fn outlet(&self) -> Div
Build the current route’s view.
Pushes this router onto the context stack so use_router()
returns this router inside views and child components.
When the route changes, the old view is dropped (its animations
clean up automatically via AnimatedValue::drop). The new view
is built fresh. Use inside a Stateful container with
route signal deps for reactive updates.