PartyKit is a collection of open-source TypeScript libraries that sit on top of Cloudflare Workers and Durable Objects to make building real-time, collaborative, and multiplayer applications dramatically simpler. Rather than writing low-level Durable Object boilerplate, you extend aDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/cloudflare/partykit/llms.txt
Use this file to discover all available pages before exploring further.
Server class, implement lifecycle hooks, and let PartyKit handle room routing, connection management, broadcasting, and hibernation — all on Cloudflare’s globally distributed edge infrastructure.
What is PartyServer?
At the core of the suite is partyserver — a TypeScript library that enhances standard Cloudflare Durable Objects with a set of ergonomic primitives:- Room-based routing — every unique room name maps to a dedicated Durable Object instance, so you never manually look up or construct Durable Object IDs.
- Lifecycle hooks —
onStart,onConnect,onMessage,onClose,onError,onRequest, andonAlarmlet you respond to every stage of a connection’s life without wiring up raw WebSocket event listeners. - Broadcasting —
this.broadcast(message, exclude?)sends a message to all connected clients in one call. - Hibernation support — a single static flag opts your server into Cloudflare’s WebSocket Hibernation API, keeping costs low when rooms are idle.
- Unified API — the same lifecycle hooks work whether hibernation is enabled or not, so you never rewrite logic when toggling the feature.
How does it differ from vanilla Durable Objects?
Writing WebSocket servers directly on top of Durable Objects requires you to manageWebSocketPair construction, manually track connected clients, iterate them to broadcast, implement the Hibernation API’s separate webSocketMessage/webSocketClose/webSocketError handlers, and orchestrate per-request initialization. PartyServer absorbs all of that complexity. You get a clean class-based interface where this.name always resolves the current room, this.broadcast() reaches every live connection, and the full lifecycle is expressed as ordinary overridable methods.
How does it differ from the original PartyKit platform?
The original PartyKit is a managed platform that auto-infers Durable Object bindings, bundles static assets, and integrates AI services. PartyServer is intentionally self-hosted and platform-agnostic:- No platform lock-in — you deploy to your own Cloudflare account with
wrangler. - Manual
wrangler.jsoncbindings — Durable Object bindings and migrations are declared explicitly, giving you full visibility and control. - No bundled services — integrations like static assets, AI, or KV are wired up through Wrangler’s native support, not through a proprietary layer.
- URL decoupling —
routePartykitRequestmaps/parties/:server/:nameURLs to DO instances, but the server name itself is decoupled from the URL, so you can address servers by session IDs or other identifiers.
Packages
The PartyKit monorepo ships several packages that work independently or together:partyserver
The core library. Extends Cloudflare Durable Objects with lifecycle hooks, room routing, broadcasting, hibernation support, and a unified WebSocket API. Start here for any real-time server.
partysocket
A resilient WebSocket client with automatic reconnection, message buffering, configurable backoff, and a
PartySocket helper that speaks the routePartykitRequest URL convention out of the box.y-partyserver
Adds Yjs CRDT support to PartyServer. Exposes a base class that handles document sync, with utility hooks for loading and saving Yjs documents to any external storage.
partysub
Pub/sub at scale. Backs a single logical “room” with multiple Durable Object instances and a configurable strategy for spreading load across Cloudflare’s global network.
partywhen
Scheduled task execution at scale. Lets you schedule work to run at a future time using Durable Object alarms without managing alarm bookkeeping yourself.
hono-party
A Hono middleware that integrates
routePartykitRequest into a Hono router, so you can mix PartyServer rooms with standard HTTP routes in the same Worker.partysync
An experimental library for synchronizing Durable Object state to connected clients, keeping the client view in sync with server-side data without manual diffing.
partytracks
Real-time media track management built on top of PartyServer, designed for applications that need to coordinate audio/video streams across participants.