Skip to main content
This walkthrough takes a better-router app from vite dev to a Cloudflare Worker with bindings on env.

1. Point Wrangler at the build

wrangler.jsonc
nodejs_compat is required for getEnv(). Static files from dist/client are served in front of the Worker. The plugin sees Wrangler and sets target: "cloudflare".

2. Bindings

Add whatever Cloudflare products you need. They show up on getEnv() / c.env during fetch.
wrangler.jsonc
src/env.d.ts
src/routes/index.server.tsx
Secrets:
Local Wrangler secrets go in .dev.vars. Full list of binding kinds: Bindings.

3. Worker entrypoint

fetch is the Hono app. Add cron, queue, or inbound email in src/worker.ts:
src/worker.ts
List the same cron in Wrangler:
Details: Worker entrypoint.

4. Deploy

After deploy:
  • / is SSR HTML with /assets/client.js
  • /api/hello is JSON from Hono
  • getEnv().DB is the D1 binding on Worker requests
  • scheduled runs when Cloudflare fires the cron
vite dev serves HTTP only. Use wrangler dev after a build when you need Miniflare bindings. A complete D1 + queue + cron app is in examples/cloudflare.