Documentation 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.
hono-party is a Hono middleware that integrates PartyServer’s Durable Object–backed WebSocket routing directly into any Hono application. You can combine REST endpoints, static file serving, and real-time multiplayer rooms all in a single Worker — no separate service needed.
Installation
Basic setup
The minimum configuration is two lines: importpartyserverMiddleware and attach it with app.use('*', ...). Any request that matches a /parties/:server/:room pattern will be routed to the appropriate Durable Object; all other requests fall through to your normal Hono routes.
Authentication with Hono context
onBeforeConnect receives the raw Request, a lobby object, and the Hono context c, which gives you access to typed environment bindings. Return a Response to reject the connection before the WebSocket handshake completes.
Error handling
Pass anonError callback to log or report errors that occur inside the middleware.
Custom routing prefix
By defaulthono-party handles the /parties/* path. Use the prefix option to scope it to a different base path.
Multiple party servers
You can export as manyServer subclasses as you need. Each class maps to its own Durable Object namespace — clients connect to party: "chat", party: "game", or party: "document" respectively.
wrangler.jsonc configuration
Each exportedServer class needs a corresponding Durable Object binding and a migration entry in your wrangler.jsonc:
React client
Connect from a React component usingusePartySocket from partysocket/react. The party field maps to the kebab-cased class name of the Durable Object.
With authentication headers
hono-party was built by Thomas Osmonson. The middleware is a thin wrapper around routePartykitRequest — all PartyServer lifecycle hooks (onConnect, onMessage, onClose, etc.) work exactly as documented in the core partyserver package.