Realtime
Real-time updates via WebSockets with Cloudflare Durable Objects.
The Quickback Stack uses Cloudflare Durable Objects to broadcast real-time updates over WebSockets. CRUD events and custom broadcasts are delivered to connected clients with the same security layers (firewall isolation, role-based filtering, field masking) applied.
Architecture
┌──────────────────────────────────────────┐
│ Quickback Worker │
│ │
│ ┌──────────┐ DO binding ┌────────────────────┐
│ │ Hono API │ ──────────────► │ Broadcaster (DO) │
│ │ │ │ WebSocket manager │
│ └──────────┘ └─────────┬──────────┘
│ │
└─────────────────────────────────────────┼┘
│ WebSocket
│
┌────────▼─────────┐
│ Browser Clients │
│ (CMS, Account, │
│ Admin, Custom) │
└──────────────────┘The Broadcaster Durable Object runs inline in your main Quickback worker — no separate worker deployment needed. The API calls the DO directly via its binding (in-process, no network hop).
- Quickback Worker — Your compiled API with the Broadcaster DO class exported from the same worker.
- Broadcaster (Durable Object) — Manages WebSocket connections per organization. One instance per org.
- Browser Clients — CMS, Account, Admin, and custom frontends connect via WebSocket on the same origin.
Key Features
| Feature | Description |
|---|---|
| Organization-scoped | Each org gets its own Durable Object instance |
| Role-based filtering | Only send events to users with matching roles |
| Per-role masking | Different users see different field values based on their role |
| User-specific targeting | Send events to a specific user within an org |
| Custom broadcasts | Arbitrary events beyond CRUD |
| Custom namespaces | defineRealtime() for type-safe event helpers |
| Ticket-based auth | HMAC-signed tickets verified at WebSocket upgrade — no HTTP round-trip |
Enabling Realtime
Add realtime to individual table definitions:
export default defineTable(applications, {
firewall: { organization: {} },
realtime: {
enabled: true,
onInsert: true,
onUpdate: true,
onDelete: true,
requiredRoles: ["recruiter", "hiring-manager"],
fields: ["id", "candidateId", "stage"],
},
});And enable the realtime binding in your database config. The compiler generates the Durable Object class, helper functions, and wrangler bindings — all within your main worker.
Pages
- Durable Objects Setup — Configuration, wrangler bindings, event formats, masking, and custom namespaces
- Using Realtime — WebSocket connection, authentication, and client-side handling