Browse guides

Connect views with the Valyrian.js router

Resolve the current browser location to one application view.

The example registers a home route, a parameterized user route and a fallback, then renders the matching outcome.

Table of contents

Main APIs

Router
Coordinates route definitions and resolves navigation through the public router flow.
mountRouter
Uses a Router as the mounted navigation root.
tsx
import { Router, mountRouter } from "valyrian.js/router";

const router = new Router();
router.add("/", () => <h1>Home</h1>);
router.add("/users/:id", (request) => <h1>User {request.params.id}</h1>);
router.catch(404, () => <h1>Not found</h1>);

mountRouter("body", router);

Error

Handle unmatched or invalid navigation through the public router error flow. Do not assume that every location resolves successfully.

Continue the cumulative application

Exact references