Skip to main content
better-router can run anywhere that speaks fetch. Cloudflare Workers is a first-class target, not the only one. If the project contains wrangler.toml, wrangler.json, or wrangler.jsonc, the plugin sets target: "cloudflare" automatically. You can also set it yourself:

What gets deployed

vite build emits: Wrangler should point at that server file and serve the client as static assets:
wrangler.jsonc
nodejs_compat is required for request-scoped helpers that use AsyncLocalStorage (getEnv(), getHonoContext()).

Deploy

Worker handlers

The generated module looks like this:
fetch is always the Hono app unless you override it in defineWorker({ fetch }). The other three no-op until you implement them. See Bindings for D1, KV, R2, Queues, and secrets. See Worker entrypoint for defineWorker.

Local development

vite dev runs the Hono fetch handler. Cron, queue, and inbound email do not fire locally. Use wrangler dev against the production build when you need Miniflare bindings (DB, KV, BUCKET, queue producers):
Put local secrets in .dev.vars, not .env, when you use Wrangler.

Example

examples/cloudflare is a Worker that uses all three:

Node, Bun, and Deno

The same worker module is a standard fetch listener. Cloudflare-only bindings (D1, R2, KV, Queues) exist on env in production. On Node, pass process.env as the second argument to worker.fetch — see Deployment.