Local development
Kilat runs locally through Wrangler (Miniflare), which provides a Workers-compatible runtime and a local D1 database — no Cloudflare account needed for development.
Start the dev server
Section titled “Start the dev server”bun run dev # wrangler devThis boots the Worker locally at http://localhost:8787.
Build first
Section titled “Build first”The Worker imports dist/manifest.json at runtime. You must run
bun run build before wrangler dev the first time, or after any client
change:
bun run build && bun run devLocal D1
Section titled “Local D1”Wrangler stores the local D1 database on disk:
.wrangler/state/v3/d1/This is a real SQLite file managed by Miniflare. Migrations applied with
--local write to this database.
Apply migrations locally
Section titled “Apply migrations locally”bun run db:migrate # wrangler d1 migrations apply kilat --localRun this after cloning and after pulling any new migration files.
Rebuild the local database
Section titled “Rebuild the local database”If your local schema gets into a bad state — or you want a clean slate — delete the state directory and re-apply migrations:
rm -rf .wrangler/state/v3/d1/bun run db:migrateThis destroys all local data. The remote (production) database is untouched.
Seed a demo user
Section titled “Seed a demo user”bun run db:seedCreates a demo user with defaults:
| Field | Default |
|---|---|
demo@example.com |
|
| Password | password123 |
| Role | user |
You can override all three:
bun run db:seed admin@example.com admin123 adminThe seed script (scripts/seed.ts) hashes the password with PBKDF2 (Web
Crypto) before inserting via wrangler d1 execute kilat --local. It skips
insertion if the user already exists.
.dev.vars for local secrets
Section titled “.dev.vars for local secrets”For local OAuth or email testing, create .dev.vars (gitignored):
GOOGLE_CLIENT_ID=your-client-idGOOGLE_CLIENT_SECRET=your-client-secretRESEND_API_KEY=re_xxxxxWrangler loads .dev.vars into env during wrangler dev, just like
wrangler secret put does in production.