Skip to main content
HTTP is the default. On Cloudflare, src/worker.ts is where you add the other Worker exports: cron, queue consumers, and inbound email. You can also wrap fetch. Node apps do not need this file. On Cloudflare these map to the Worker scheduled, queue, and email exports. See Cloudflare Workers and Bindings.

src/worker.ts

src/worker.ts
The generated worker exports:
If this file is missing, fetch still serves the Hono app. The other handlers exist and do nothing. On Node and Bun, vite only serves fetch. The other handlers still exist on dist/server so a host can call them.

Override fetch

Leave fetch unset to use the generated Hono app. Set it when you need to intercept the request first:
src/worker.ts
Most apps should omit fetch and keep pages and APIs on Hono.

Bindings in handlers

Non-HTTP handlers do not run inside the request AsyncLocalStorage context. getEnv() throws there. Use the env argument:
src/worker.ts
Inside loaders, actions, and middleware, getEnv() is the same object as this env.

Wrangler must list triggers

Cloudflare Cron Triggers must list the same expressions in wrangler.jsonc. Implementing scheduled in source is not enough for Cloudflare to fire the alarm.
A full app with D1, a queue producer/consumer, and cron is in examples/cloudflare.

Local

vite dev does not run scheduled, queue, or email. Use wrangler dev after vite build to exercise those handlers with Miniflare.