PartyKit is a real-time collaboration platform built on Cloudflare Durable Objects. Each room is a persistent server instance that handles WebSocket connections, shared state, and broadcasting — all deployed globally at the edge.
0 / 5 completed
1 / 5
What is PartyKit?
PartyKit is a developer platform built on Cloudflare Durable Objects that makes real-time collaborative apps easy. Each room is a persistent 'party' with its own server instance, WebSocket connections, and state, deployed globally at the edge without managing infrastructure.
2 / 5
What interface must a PartyKit server class implement?
A PartyServer class implements the Party.Server interface from partykit/server. The onConnect(conn, room) method handles new connections, onMessage(message, sender, room) processes incoming messages, and the class exports as the party's main entry point.
3 / 5
What does the room.broadcast(message, exclude) method do in PartyKit?
room.broadcast(message, excludeIds) sends a message to every connected client in the current room. The optional second argument is an array of connection IDs to skip — commonly used to exclude the sender so they do not receive their own message echoed back.
4 / 5
What is hibernation in PartyKit and why is it important?
Hibernation allows a PartyKit room's Durable Object to be evicted from memory when all connections are idle, stopping CPU billing. WebSocket connections are preserved by the Cloudflare runtime, and the Durable Object is rehydrated when the next message arrives. This makes it cost-effective to keep thousands of idle rooms running.
5 / 5
How do you connect a client to a PartyKit room from the browser?
PartySocket from the partysocket npm package is the recommended client. It wraps WebSocket with automatic reconnection, exponential backoff, and convenience APIs. In React, the usePartySocket hook manages the connection lifecycle and event listeners within component state.