OPEN SOURCE · 2023
route-schema.
Type-safe routes for typed APIs
Context
In most TypeScript codebases, URLs are strings with the type system switched off. Change a parameter name in one place and the links built in nine others break silently at runtime — a category of bug that shouldn't exist in a typed language.
The problem
The fix had to be adoptable: no build step, no generated files to drift, no runtime cost — or teams would simply keep writing template strings.
My role
Author and maintainer.
What made it technically interesting
Inferring both the builder's signature and the parameter types from a single route declaration, without codegen, requires pushing TypeScript's template literal types to their practical limits.
The value proposition is smallness — every feature that adds runtime weight works against adoption.
Decisions
- Inference over codegen
- Types are derived from the declaration itself, so there is no build step to maintain and no generated file to drift from source.
- Zero runtime by default
- The type layer does the work at compile time; the runtime surface is one small parse function. Small API, small bundle, easy adoption.
Result
- Building a URL with missing or mistyped parameters is a compile error instead of a production bug.
- The library ships under 2kB with zero dependencies.
What I learned
The type system is a design tool, and restraint is a feature — the best library is often the one that refuses to grow.
Have a project in this space?
Let's talk about it