MIT licensed · zero dependencies
A router that doesn't need a config file to explain itself.
routewise is a 4KB routing library for small services — pattern matching, typed params, no middleware chain you need a diagram to understand.
# install
npm install routewise
npm install routewise
Quick start
import { router } from 'routewise';
const app = router();
app.get('/users/:id', (req) => {
return { id: req.params.id };
});
// params are typed from the pattern string itself
app.listen(3000);
const app = router();
app.get('/users/:id', (req) => {
return { id: req.params.id };
});
// params are typed from the pattern string itself
app.listen(3000);
Why another router
No implicit middleware order
Every handler declares exactly what runs before it. Nothing is inherited by accident.
Params typed from the pattern
:id in the route string gives you a typed req.params.id — no separate schema.
4KB, no dependencies
Vendor it directly if you want. We won't be offended.
One file you can actually read
The whole matcher is under 300 lines. Reading the source is a legitimate way to learn it.