modernjs-typed-routes
Type-safe routes for Modern.js

Generated route types + typed Link, Navigate and useNavigate. Path typos and missing params become compile errors.

⚑

Zero config

Add one plugin to modern.config.ts. Types regenerate automatically on every route change, in dev and build.

πŸ—ΊοΈ

Every convention covered

Dynamic [id], optional [id$], splat $, pathless __layouts, flat a.b.c segments, config routes and multi-entry apps β€” derived from Modern.js's own route parser, not a re-implementation.

πŸ›‘οΈ

Typed navigation, not just types

Ships typed Link, Navigate and useNavigate wrappers. Paramless routes accept a plain string; routes with params require them β€” autocompleted and typechecked.

πŸͺΆ

Zero runtime cost

Generates a single .d.ts file β€” declaration merging does the rest. Nothing is added to your bundle beyond tiny static wrappers.

βœ…

CI friendly

npx modern typegen generates types without a dev server, so `typegen && tsc --noEmit` catches broken links in CI.

πŸ”“

Escape hatches included

Full re-export of @modern-js/runtime/router, originalNavigate for raw navigation, and a RoutePathname union for your own APIs.