Node File Router


A powerful file-based routing for Node.js.
- Technology Agnostic:
- Pure Node HTTP
- Bun
- Express
- Sockets
- ... whatever compatible with the interface
- 0 dependencies
- CommonJS and ES modules support
- TypeScript support
- 100% test coverage
api/
├── profile/
│ └── orders.[post].ts - methods in any filenames
├── catalog/
│ └── [[...tags]].ts - several segments
├── collection/
│ └── [cid]/ - slugs in folders
│ └── products/
│ └── [pid].ts - slugs in files
├── index.ts - root
└── _404.ts - not found response
- [POST]: /profile/orders →
/api/profile/orders.[post].ts
- /catalog/men/black/denim →
/api/catalog/[[...tags]].ts
- /collection/77/products/13 →
/api/collection/[cid]/products/[pid].ts
- / →
index.ts
Methods in a file:
export default {
get(req, res, routeParams) {},
post(req, res, routeParams) {},
patch(req, res, routeParams) {},
}
Single response function:
export default function (req, res, routeParams) {}
Documentation
Visit website to get started and view
the full documentation.
Usage:
Methods routing:
Route matching:
Support other protocols and frameworks:
Examples
Visit examples folder to see samples with
different module systems, adapters, and use cases.
Developing
To begin development and contribution, read this guide.
Ask questions, voice ideas, and share your projects on Github Discussion.