Development Experience
bkper app dev starts the full local development environment in one command: Vite HMR for the UI, Miniflare for the Workers runtime, and an automatic Cloudflare tunnel so Bkper routes webhook events to your laptop.
The bkper app dev command starts your entire development environment with a single command.
What it starts
bkper app devThis orchestrates:
- Vite dev server — HMR for the client UI. Changes to Lit components reflect instantly in the browser.
- Miniflare — Simulates the Cloudflare Workers runtime locally for the web server and events handler.
- Cloudflare tunnel — Exposes the events handler via a public URL so Bkper can route webhook events to your machine.
- File watching — Server and shared package changes trigger automatic rebuilds.
URLs
| Handler | URL |
|---|---|
| Web (client + server) | http://localhost:8787 |
| Events (via tunnel) | https://<random>.trycloudflare.com/events |
The tunnel URL is automatically registered as the webhookUrlDev in Bkper, so events from books where you’re the developer are routed to your local machine.
Configuration flags
You can run specific handlers independently:
# Start only the web handlerbkper app dev --web
# Start only the events handlerbkper app dev --events
# Override default portsbkper app dev --cp 5173 --sp 8787 --ep 8791
# Don't open the browser automaticallybkper app dev --no-openLocal secrets
Environment variables for local development live in a .dev.vars file at the project root:
# .dev.vars (gitignored)BKPER_API_KEY=your-api-key-hereCopy from the provided template:
cp .dev.vars.example .dev.varsThese variables are available as c.env.SECRET_NAME in your Hono handlers during development.
KV storage
KV data persists locally in the .mf/kv/ directory during development. This means your data survives restarts — useful for testing caching and state patterns.
// Readconst value = await c.env.KV.get('my-key');
// Write with TTLawait c.env.KV.put('my-key', 'value', { expirationTtl: 3600 });See the Cloudflare KV documentation for more usage patterns.
Type generation
The env.d.ts file provides TypeScript types for the Worker environment — KV bindings, secrets, and other platform services. It’s auto-generated based on your bkper.yaml configuration and checked into version control.
Rebuild it after changing services or secrets in bkper.yaml:
bkper app buildThe development loop
- Run
bkper app dev - Edit client code — see changes instantly via HMR
- Edit server code — auto-rebuilds and reloads
- Trigger events in Bkper — your local handler receives them via the tunnel
- Check the activity stream in Bkper to see handler responses
- Iterate
Debugging
- Server errors — Check the terminal output from
bkper app dev. Worker runtime errors appear here. - Event handler errors — Check the Bkper activity stream. Click on an event handler response to see the result or error, and replay failed events.
- Client errors — Use browser DevTools. The Vite dev server provides source maps.