Skip to content

Deployment

Kilat deploys to Cloudflare Workers — serverless, no Docker, no VPS, no load balancer to configure. Your app runs across 300+ edge locations automatically.

Terminal window
# 1. Build the client bundle (esbuild → dist/)
bun run build
# 2. Apply D1 migrations to the remote database
wrangler d1 migrations apply kilat --remote
# 3. Deploy the Worker
wrangler deploy

That’s it. wrangler deploy uploads the Worker bundle and routes traffic globally within seconds.

Kilat uses environment-specific configs ([env.staging] and [env.production] in wrangler.toml). Deploy to a specific environment:

Terminal window
# Deploy to staging
wrangler deploy --env staging
# Deploy to production
wrangler deploy --env production
  • Worker — your Hono app runs at the nearest of 300+ Cloudflare locations to each visitor. No cold starts in the traditional sense; Workers isolate startup is sub-millisecond.
  • D1 — your SQLite database replicates read-only copies to the nearest edge. Writes go to the primary, reads hit the local replica — low latency without managing replicas yourself.
  • Static assetsdist/ is served via the Workers Static Assets binding (env.ASSETS). run_worker_first = ["/*", "!/assets/*"] means /assets/* bypass the Worker entirely for maximum speed; everything else hits your app first.

There is no container to build, no server to provision, no process manager to keep alive. Wrangler handles upload and global distribution. You never SSH into anything.

  1. Set your secretswrangler secret put for RESEND_API_KEY, GOOGLE_CLIENT_ID, GOOGLE_CLIENT_SECRET, etc. Use --env production for production secrets (e.g. wrangler secret put RESEND_API_KEY --env production). See Configuration.
  2. Set NODE_ENV = "production" — enables secure cookies and production behavior.
  3. Create the R2 bucket and KV namespace — Kilat needs an R2 bucket for avatar storage and a KV namespace for rate limiting:
    Terminal window
    npx wrangler r2 bucket create kilat-avatars
    npx wrangler kv namespace create RATE_LIMIT_KV
    Update the placeholder IDs in wrangler.toml with the returned IDs.
  4. Run migrations with --remote (not --local) — your local D1 is a separate database.

Re-run the same three commands. Wrangler handles atomic swaps — in-flight requests finish on the old version, new requests hit the new one. Migrations are forward-only; never edit an applied migration (see Schema & migrations).

Want https://yourdomain.com instead of *.workers.dev? See Custom domain.