JSPM

itty-router

4.3.0-next.4
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 145857
  • Score
    100M100P100Q170826F
  • 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


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

Features

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

Documentation