Lifecycle
Realtime rooms move through a simple lifecycle:
active: the room has recent activity or live connections.idle: the room has no live connections after the configured idle window.destroyed: the room was closed and writes are rejected unless recreation is enabled.
Configure lifecycle behavior when you create the Realtime instance:
const live = realtime({ name: "live", lifecycle: { idleTtlSeconds: 300, destroyTtlSeconds: 86400, allowRecreate: false, },})Check room state
Section titled “Check room state”Use lifecycle() when a user opens a document, rejoins a room, or when an
admin screen needs to show whether a room is active:
app.get("/rooms/:roomId/lifecycle", async (request) => { const pathSegments = new URL(request.url).pathname.split("/") const roomId = pathSegments[2]
return await live.room(roomId).lifecycle()})Example result:
{ room: "room_123", kind: "room", status: "active", activeConnections: 3, lastActivityAt: "2026-05-25T00:00:00.000Z"}Destroy a room
Section titled “Destroy a room”Use destroy() when a room, document, or channel should be closed:
await live.room("room_123").destroy()Destroying a room closes live connections, clears hot Durable Object state, and marks the room as destroyed in Realtime state. History, snapshots, and CRDT updates stay available by default.
To remove stored records for that room:
await live.crdtRoom("document_123").destroy({ deleteHistory: true, deleteSnapshots: true, deleteCrdtUpdates: true,})After destroy
Section titled “After destroy”With the default allowRecreate: false, future writes to the same room name
fail. Set allowRecreate: true when your app uses reusable room names, such as
temporary meeting rooms or test rooms.
Durable Object storage is used for hot room state: connections, awareness, merged Yjs updates, state vectors, idle markers, and destroyed markers. The Database product remains the persistent product boundary for room history, snapshots, CRDT records, and lifecycle metadata.
WebSocket hibernation
Section titled “WebSocket hibernation”Realtime rooms use Cloudflare Durable Object WebSocket hibernation for long lived connections. When a room is idle, Cloudflare can evict the Durable Object from memory while keeping WebSocket clients connected at the edge. When a message arrives, the Durable Object wakes up and restores each connection from its socket attachment.
Realtime stores only small per-connection fields in the WebSocket attachment: client id, member id, presence summary, subscription details, and timestamps. Larger room data, history, snapshots, CRDT updates, and lifecycle records stay in the Database product.
This keeps active collaboration responsive while reducing idle connection duration costs.