<Router>
The main router component that provides routing context.
import { Router } from "@funstack/router";
<Router
routes={routes}
onNavigate={(event, info) => {
console.log("Navigating to:", event.destination.url);
console.log("Matched routes:", info.matches);
console.log("Will intercept:", info.intercepting);
}}
/>Props
| Prop | Type | Description |
|---|---|---|
routes | RouteDefinition[] | Array of route definitions |
onNavigate | OnNavigateCallback | Callback fired before navigation is intercepted. Receives the NavigateEvent and an info object with matched routes and whether the router will intercept the navigation. |
fallback | "none" | "static" | Fallback mode when Navigation API is unavailable. "none" (default) renders nothing; "static" renders matched routes using window.location without navigation interception (MPA behavior). |
ssr | SSRConfig | SSR configuration for route matching during server-side rendering. Accepts an object with path (the pathname to match against) and an optional runLoaders boolean (defaults to false). When runLoaders is false, routes with loaders are skipped during SSR. Once the client hydrates, the real URL from the Navigation API takes over. See the SSR guide for details. |