Package Exports
- itty-router
- itty-router/AutoRouter
- itty-router/IttyRouter
- itty-router/Router
- itty-router/StatusError
- itty-router/cors
- itty-router/createResponse
- itty-router/error
- itty-router/html
- itty-router/jpeg
- itty-router/json
- itty-router/png
- itty-router/status
- itty-router/text
- itty-router/webp
- itty-router/websocket
- itty-router/withContent
- itty-router/withCookies
- itty-router/withParams
Readme
An ultra-tiny API microrouter, for use when size matters (e.g. Cloudflare Workers).
Features
- Tiny. We have routers from ~450 bytes to a ~1kB bytes batteries-included version. For comparison, express.js is over 200x as large.
- Web Standards - Use it anywhere, in any environment.
- No assumptions. Return anything you like, pass in any arguments you like.
- Future-proof. HTTP methods not-yet-invented already work with it.
- Route-parsing & query parsing.
- Middleware - use ours or write your own.
- Nesting.
Example (Cloudflare Worker or Bun)
import { AutoRouter } from 'itty-router' // ~1kB
const router = AutoRouter()
router
.get('/hello/:name', ({ name }) => `Hello, ${name}!`)
.get('/json', () => [1,2,3])
.get('/promises', () => Promise.resolve('foo'))
export default router
// that's it ^-^Full Documentation @ itty.dev
Complete API documentation is available at itty.dev/itty-router, or join our Discord channel to chat with community members for quick help!
Join the Discussion!
Have a question? Suggestion? Idea? Complaint? Want to send a gift basket?
Join us on Discord!
Special Thanks: Contributors
These folks are the real heroes, making open source the powerhouse that it is! Help out and get your name added to this list! <3
Constant Feedback, Suggestions, Moral Support & Community Building
- TBD
Core Concepts
- @mvasigh - proxy hack wizard behind itty, coding partner in crime, maker of the entire doc site, etc, etc.
- @hunterloftis - router.handle() method now accepts extra arguments and passed them to route functions
- @SupremeTechnopriest - improved TypeScript support and documentation! :D
Code Golfing
- @taralx - router internal code-golfing refactor for performance and character savings
- @DrLoopFall - v4.x re-minification
Fixes & Build
- @taralx - QOL fixes for contributing (dev dep fix and test file consistency) <3
- @technoyes - three kind-of-a-big-deal errors fixed. Imagine the look on my face... thanks man!! :)
- @roojay520 - TS interface fixes
- @jahands - v4.x TS fixes
- and many, many others