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
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
fetch and keep pages and APIs on Hono.
Bindings in handlers
Non-HTTP handlers do not run inside the requestAsyncLocalStorage context. getEnv() throws there. Use the env argument:
src/worker.ts
getEnv() is the same object as this env.
Wrangler must list triggers
Cloudflare Cron Triggers must list the same expressions inwrangler.jsonc. Implementing scheduled in source is not enough for Cloudflare to fire the alarm.
examples/cloudflare.
Local
vite dev does not run scheduled, queue, or email. Use wrangler dev after vite build to exercise those handlers with Miniflare.