A modern Cloudflare Workers starter with:
honofor routingvite@8for local DX + build- Cloudflare D1 +
drizzle-ormfor data better-authfor auth endpoints- React SSR example route (
renderToString)
bun install
cp .dev.vars.example .dev.vars
bun run devOpen:
http://127.0.0.1:5173/http://127.0.0.1:5173/authhttp://127.0.0.1:5173/react-ssrhttp://127.0.0.1:5173/api/health
- Create D1 database:
bun run db:create- Put returned IDs in
wrangler.jsonc:
database_idpreview_database_id
- Generate and apply schema:
bun run db:generate
bun run db:migrate:local
# then for real environment
bun run db:migrate:remoteSet .dev.vars:
BETTER_AUTH_SECRET=replace-with-a-long-random-secret
BETTER_AUTH_URL=http://127.0.0.1:5173
BETTER_AUTH_TRUSTED_ORIGINS=http://localhost:5173,http://127.0.0.1:5173Auth endpoints are mounted at:
/api/auth/*- session helper route:
/api/session
bun run dev- local dev with Vite + Hono CF adapterbun run dev:wrangler- run worker with Wrangler directlybun run typecheck- TypeScript checkbun run build- production build (dist/_worker.js)bun run deploy- build + Cloudflare deploybun run db:generate- generate Drizzle SQL migrationsbun run db:migrate:local- apply migrations to local D1bun run db:migrate:remote- apply migrations to remote D1bun run db:studio- launch Drizzle Studiobun run cf-typegen- regenerate Cloudflare binding types
bun run deployThis deploys dist/_worker.js through Wrangler.