Runtimes
Runtimes > Cloudflare Workers - itty-router
Itty-router was originally designed for Cloudflare Workers, and remains its optimization target to this day.
js
import { AutoRouter } from 'itty-router'
const router = AutoRouter()
router.get('/', () => 'Success!')
export default router // see note below
Currently, there's a bug in Wrangler that affects local development using wrangler dev
when trying to export the router directly. We're working with the Cloudflare folks to get this fixed ASAP.
In the meantime, destructure your root router like this to avoid the issue:
ts
export default { ...router } // this looks pointless, but trust us