
Blazor WASM has a built-in client-side router. Routes are defined on components using the @page directive. The router intercepts navigation and renders the matching component without a full page reload.
@page "/products"
@page "/shop" // multiple routes for same component
<h1>Products</h1>@page "/product/{Id:int}"
@code {
[Parameter] public int Id { get; set; }
}@inject NavigationManager Nav
Nav.NavigateTo("/products");Use <NavLink> instead of <a> — it automatically adds the active CSS class when the route matches:
<NavLink href="/products" Match="NavLinkMatch.All">Products</NavLink>Add a catch-all route in App.razor using the <NotFound> template inside the Router component.
Reference:
TaskLoco™ — The Sticky Note GOAT