Routing
Declare routes, render the match in the current window, and navigate with push / replace.
#Routes
let router = Router::new(
[
RouteDefinition::new("home", "/"),
RouteDefinition::new("project", "/projects/:id"),
],
"/",
)?;RouteDefinition::layout declares a pathless ancestor. Relative child paths join their parent; an absolute child path starts at the root.
#Nested layouts
Match the route chain and wrap inner content with layout elements. Pathless layouts appear in the match without adding a URL segment.
RouteDefinition::layout("shell").parent("root")#Navigation
self.router.push("/projects/42")?;
cx.invalidate();The controller supports push, replace, back, and forward. Navigation stays inside the app.
#Route parameters
if let Some(matched) = self.router.matched() {
let id = matched
.params()
.iter()
.find(|param| param.name() == "id")
.map(|param| param.value())
.unwrap_or("");
text(format!("Project {id}"))
} else {
text("Page not found")
}