A Cloudflare Workers setup using the "UI local, code remote" approach. This architecture provides:
- Flexible Development: Make configuration adjustments using the bknd Admin UI with full type safety
- Automatic Sync: Configuration changes are automatically synchronized across your codebase
- Production Security: Deploy a locked-down, code-only version that prevents runtime modifications
Development Mode: Flexible, UI-driven configuration with real-time synchronization Production Mode: Static configuration with environment-injected secrets and zero runtime modifications
-
Split Configuration
bknd.config.ts- CLI configuration with platform proxy for Cloudflare resource accessconfig.ts- App configuration that prevents bundling CLI dependencies with your worker
-
File Synchronization
- Wrangler's
unenvprevents filesystem access - Built-in
devFsWritehelpers use STDIO to synchronize configuration files
- Wrangler's
-
Mode Switching
- Development: "db" mode with UI-driven configuration
- Production: "code" mode with static configuration and environment secrets
dev- Vite development server for UIdev:cf- Cloudflare Workers development serverpredev- Auto-generates configuration before development
deploy- Deploy to Cloudflare Workers productionpredeploy- Auto-generates production configurationpreview- Test production mode locally
bknd- Base CLI command with proxy and TypeScript supportbknd:types- Generate TypeScript definitionsbknd:config- Export configuration toappconfig.jsonbknd:secrets- Generate.env.exampletemplatebknd:assets- Copy UI assets topublic/
typegen- Generate Wrangler and bknd typespostinstall- Auto-setup after installation (config, types, secrets, assets)
- Install:
npm install - Develop:
npm run dev - Deploy:
npm run deploy
- Create required Cloudflare resources:
npx wrangler d1 create <database-name> - Update
wrangler.jsonwith your resource IDs
- Set environment variables via Wrangler CLI or Cloudflare Dashboard
- Variables should match those in your generated
.env.example
Generate a template with: npm run bknd:secrets