JSPM

itty-router

6.0.0
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 146436
  • Score
    100M100P100Q180895F
  • License MIT

A tiny, zero-dependency router, designed to make beautiful APIs in any environment.

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

Itty Router

npm version bundle size build status code coverage weekly downloads open issues
join us on discord repo stars follow ittydev

v5 Documentation  |   v4 -> v5 Migration Guide  |   Discord


An ultra-tiny API microrouter, for use when size matters (e.g. Cloudflare Workers).

Features

Example

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 ^-^

Need Help?

Complete API documentation is available on itty.dev, 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!

A Special Thanks ❤️

As the community and contributor list has grown (and thus an individualized list here is no longer easily maintainable), I'd like to thank each and every one of you for making itty far greater than its humble origins. The robustness you see today, the careful consideration of every byte spent on features, the API choices, the code-golfing itself... are all thanks to the efforts and feedback from the community. I'd especially like to thank the core contributors and PR-authors, as well as the fantastic folks on the itty Discord group, for their tireless work refining this little beast and answering community questions.