Documentation
Docs
Introduction
Getting Started
Tutorial: build an app
Core Concepts
Routing
Server-Side Rendering
Mimir, state management
Pages & Layouts
API Routes
Styling & Theming
Building & Deploying
API Reference
Guides
Recipes
FAQ (use cases)
Reference , ekko:rune/router
Client navigation and location hooks. Import:
See The router and Navigation for the narrative.
useRouter() → router
| Field | Type | Description |
|---|---|---|
path | string | Current pathname. |
params | object | Route params from the matched pattern. |
query | object | Parsed query object. |
navigate | (href, opts?) => void | Client navigation (no reload). |
back | () => void | History back. |
forward | () => void | History forward. |
Subscribes the component to route changes (re-renders on navigation, including back/forward).
useParams() → object
The route params for the current match ({ id } for /items/:id). Subscribes to changes.
useSearchParams() → object
The query string parsed to an object (from location.search). Empty object on the server.
navigate(href, opts?) → void
Imperative client navigation. Matches href against the client route table, imports the target chunk, renders
in place, updates history. No-op on the server.
<Link href={...}>
Renders a real <a href> and intercepts the click for client navigation. Crawlable, middle-clickable, works
without JS (falls back to a normal navigation). Use for in-app links; use a plain <a> for external URLs.
Behaviour notes
- Matching: the client matches against
__routes({ pattern, pageFile, guard }), sorted static →
dynamic → catch-all, the same priority order as the server.
- Caching: a route's chunk is fetched on first navigation and cached thereafter;
modulepreloadwarms the
current page's chunks.
- Guards: a route registered with
meta.guard = { redirect }carries that into__routes[].guard; the
client router can redirect before rendering the guarded page. See Guards & redirects.
- Server vs client: on the server
navigateis a no-op and the hooks read the request; in the browser they
are live. The same component code works in both.
__routerConfig
Advanced router configuration baked into the page (from the router's toClientConfig()):
| Field | Description |
|---|---|
backRules | Rules for the browser Back button: match a path (string/regex) and goTo a destination or skip the entry. |
beforeUnload | Guards that run before a navigation/unload (e.g. unsaved-changes warnings). |
Next: ekko:rune/mimir.