Guide
When a Room DO hibernates, WebSockets drop and wake again. FluxyChat’s SDK handles the client experience: backoff, connectionState, and history replay via loadMore.
Durable Objects can hibernate idle WebSocket connections to save resources. When clients reconnect, the DO accepts a new upgrade and resumes fan-out, but messages sent while a client was offline are not magically replayed over the socket alone.
That is why production chat pairs live WebSocket events with persisted history in D1.
Long-lived sessions need the JWT refreshed before `exp` to avoid a 1008 close mid-session. The SDK passes the token on the WS URL. Re-connecting with a fresh JWT keeps the user online without an explicit reconnect trigger.
import { FluxyChatClient } from "@fluxy-chat/sdk";
import { useChat } from "@fluxy-chat/react";
const client = new FluxyChatClient({ baseUrl, userId, token });
function Room({ roomId }: { roomId: string }) {
const { messages, sendMessage, connectionState, loadMore, hasMore, retryMessage } =
useChat({ roomId, client });
return (
<div>
<p>
{connectionState.status}
{connectionState.nextRetryAt
? ` · retry ${connectionState.nextRetryAt}`
: null}
</p>
{hasMore ? (
<button type="button" onClick={() => void loadMore()}>
Load older messages
</button>
) : null}
{messages.map((m) => (
<div key={m.id}>
{m.content}
{m.deliveryStatus === "failed" ? (
<button type="button" onClick={() => retryMessage(m.clientMessageId!)}>
Retry
</button>
) : null}
</div>
))}
</div>
);
}import { FluxyChatClient, createFluxyRoomSession } from "@fluxy-chat/sdk";
const client = new FluxyChatClient({ baseUrl, userId, token });
const { store, stop } = createFluxyRoomSession({ roomId: "support-1", client });
store.subscribe((state) => {
console.log(state.connectionState, state.messages.length);
});
// After reconnect: store.getState().loadMore()
// Cleanup: stop();FluxyChat packages the same stack: RoomDurableObject, D1 history, multi-tenant JWT, reconnect-aware SDK, and operator console. MIT self-host or hosted beta.
Topics: durable objects websocket hibernation · websocket reconnect cloudflare · chat message replay · loadMore chat history
Canonical path: /guides/reconnect-durable-objects-hibernation