Deployment
Kilat deploys to Cloudflare Workers — serverless, no Docker, no VPS, no load balancer to configure. Your app runs across 300+ edge locations automatically.
The three-command deploy
Section titled “The three-command deploy”# 1. Build the client bundle (esbuild → dist/)bun run build
# 2. Apply D1 migrations to the remote databasewrangler d1 migrations apply kilat --remote
# 3. Deploy the Workerwrangler deployThat’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:
# Deploy to stagingwrangler deploy --env staging
# Deploy to productionwrangler deploy --env productionWhat happens at the edge
Section titled “What happens at the edge”- 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 assets —
dist/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.
No Docker, no VPS
Section titled “No Docker, no VPS”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.
Before you deploy
Section titled “Before you deploy”- Set your secrets —
wrangler secret putforRESEND_API_KEY,GOOGLE_CLIENT_ID,GOOGLE_CLIENT_SECRET, etc. Use--env productionfor production secrets (e.g.wrangler secret put RESEND_API_KEY --env production). See Configuration. - Set
NODE_ENV = "production"— enablessecurecookies and production behavior. - Create the R2 bucket and KV namespace — Kilat needs an R2 bucket for
avatar storage and a KV namespace for rate limiting:
Update the placeholder IDs in
Terminal window npx wrangler r2 bucket create kilat-avatarsnpx wrangler kv namespace create RATE_LIMIT_KVwrangler.tomlwith the returned IDs. - Run migrations with
--remote(not--local) — your local D1 is a separate database.
Deploying updates
Section titled “Deploying updates”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).
Custom domain
Section titled “Custom domain”Want https://yourdomain.com instead of *.workers.dev? See
Custom domain.