@intent-framework/router
v0.1.0-alpha.10
Published
Typed route definitions and navigation for Intent
Readme
@intent-framework/router
Typed route definitions and navigation for Intent.
Install
pnpm add @intent-framework/core @intent-framework/routernpm install @intent-framework/core @intent-framework/routerQuick reference
createRouter()
import { createRouter } from "@intent-framework/router"
const router = createRouter()
.route("home", "/", HomeScreen)
.route("team", "/teams/:teamId", TeamScreen)| Method | Description |
|--------|-------------|
| .route(name, path, screen) | Register a route with typed params |
| .match(pathname) | Match a pathname → { found, name, params, screen } |
| .path(name, params?) | Generate a typed path string |
| .routes() | List all registered route definitions |
Typed navigation
import type { RouterServices, RoutesFromPaths, RouterNavigate, RouteContext } from "@intent-framework/router"
const appPaths = { home: "/", team: "/teams/:teamId" } as const
type AppRoutes = RoutesFromPaths<typeof appPaths>
// Typed navigate function
type Navigate = RouterNavigate<AppRoutes>
// (name: "home") => void
// (name: "team", params: { teamId: string }) => void
// Full services with navigate + extras
type AppServices = RouterServices<AppRoutes, {
route: RouteContext<AppRoutes>
analytics: { track(event: string): void }
}>DOM rendering
import { renderRouter } from "@intent-framework/dom"
renderRouter(router, {
target: document.getElementById("root")!,
notFound: NotFoundScreen,
services: { /* custom services */ },
})renderRouter() injects navigate (and route when matched) into screen services, listens for popstate to handle back/forward, and cleans up on dispose().
Guide
See docs/Router.md for the full router guide covering typed navigation, route params, services, popstate behavior, renderRouter options, and current non-goals.
Where this fits
Router provides typed route definitions and navigation for Intent screens. Use @intent-framework/dom's renderRouter() to materialize navigation into the DOM. The router does not own the product model — it maps paths to screens.
Learn more
- Router guide — comprehensive guide
- Root README — project overview and philosophy
- MVP Checkpoint — current implementation boundaries
- Web basic example — full demo with routing, resources, and diagnostics
Status
Experimental alpha. APIs may change. Not recommended for production use.
