Presence + chat (WebSocket DO)
Connects via /api/ws/connect to a Durable Object inside this same worker. Open this page in two browser windows — you'll see the count tick up and chat messages appear in both.
disconnectedconnecting…
- No messages yet — send the first chat or hit "server broadcast".
The DO uses the Hibernation API — when no messages flow it pays nothing. Each browser sees its own random ID; messages from "you" are highlighted. The "server broadcast" button hits a regular HTTP POST endpoint that the worker forwards to the same DO.