Installation
Prerequisites
Section titled “Prerequisites”- Bun >= 1.3 — package manager and script runner (install). The app runs on Cloudflare Workers, not Bun — Bun only installs deps and runs scripts.
- Cloudflare account — free tier is enough (sign up).
- Wrangler — included as a devDependency, or install globally with
npm i -g wrangler.
Scaffold a new project
Section titled “Scaffold a new project”bun create kilat@latest my-appcd my-appThe interactive prompt picks a framework (React 19 / Svelte 5 / Vue 3) and
styling (vanilla CSS / Tailwind CSS v4). It downloads the template, patches
wrangler.toml, renames package.json, and runs bun install.
bun create kilat my-app --template svelte-tailwind # skip promptsbun create kilat . # use current dirManual clone
Section titled “Manual clone”Alternatively, clone directly:
git clone https://github.com/maulanashalihin/kilat.git my-appcd my-appbun installConfigure wrangler.toml
Section titled “Configure wrangler.toml”Open wrangler.toml and set your D1 database ID and app URL:
name = "my-app"main = "src/worker.ts"compatibility_date = "2025-07-01"compatibility_flags = ["nodejs_compat"]
[vars]NODE_ENV = "development"APP_URL = "http://localhost:8787"SSR = "true"MAIL_DRIVER = "log"MAIL_FROM = "no-reply@example.com"
[[d1_databases]]binding = "DB"database_id = "your-database-id-here" # from `wrangler d1 create`database_name = "kilat"migrations_dir = "migrations"
[assets]directory = "./dist"binding = "ASSETS"run_worker_first = ["/*", "!/assets/*"]Sensitive values (API keys, OAuth secrets) should use wrangler secret put
instead of [vars].
Local development
Section titled “Local development”# 1. Create a D1 database (first time only)npx wrangler d1 create kilat# → copy the database_id into wrangler.toml
# 2. Apply migrations to local D1bun run db:migrate
# 3. Build client assets (required before first dev run)bun run build
# 4. Run the dev serverbun run dev # http://localhost:8787Run bun run build again whenever client assets change — the Worker imports
dist/manifest.json at module load.
Production deploy
Section titled “Production deploy”# 1. Create the remote D1 database (first time only)npx wrangler d1 create kilat# → copy the database_id into wrangler.toml
# 2. Apply migrations to remote D1npx wrangler d1 migrations apply kilat --remote
# 3. Build client assetsbun run build
# 4. Deploy to Workers edgebun run deploy# → https://<your-worker>.<your-subdomain>.workers.devThat’s it. No Docker, no VPS, no reverse proxy. The Worker runs on Cloudflare’s edge network — 300+ locations worldwide. D1 replicates read-only copies to the nearest edge automatically.
Scripts
Section titled “Scripts”| Command | What it does |
|---|---|
bun run dev |
Wrangler dev server (local D1 + Workers runtime) |
bun run build |
esbuild client assets → dist/ (+ manifest.json) |
bun run deploy |
wrangler deploy to Cloudflare Workers edge |
bun run db:migrate |
Apply D1 migrations locally |
bun run db:migrate:remote |
Apply D1 migrations to remote (production) |
bun run db:seed |
Create a demo user ([email] [password] [role] args) |
bun run typecheck |
tsc --noEmit |
bun run test |
E2E suite (bun test --isolate) |
Next steps
Section titled “Next steps”- Configuration — the full env var reference.
- Custom domain — point a domain at your Worker.
- Schema & migrations — managing D1 schema changes.