Cookbook
Practical recipes for building with Starfish. Each recipe solves a specific problem with working code examples in TypeScript, Python, and Swift.
Recipes
Getting Connected
- Connect with Automatic Reconnection — configure resilient connections that recover from network failures
- Handle Connection State Changes — react to connection lifecycle events
Sessions & Presence
- Join a Session and Track Who's Online — monitor connected clients with Presence
Messaging
- Publish/Subscribe to a Topic — basic pub/sub messaging pattern
- Send Reliable vs Unreliable Messages — choose the right delivery mode
- Broadcast to Specific Clients — send messages to selected recipients
- Request/Reply Pattern — RPC-style communication with
replyTo
Matchmaking
- Random Pairing with Auto Mode — pair strangers automatically with pools
- Attribute Filtering — match only compatible clients with
filter - Custom Matchmaker with Delegated Mode — form groups yourself with
assign() - Re-pairing When a Peer Disconnects — find a new partner when yours leaves
Data & State
- Store and Sync Shared State — use state operations for collaborative state
Advanced
- Filter Events by Type or Topic — selectively handle events
- Use WebRTC Data Channels — low-latency peer-to-peer messaging
- Share Realtime Media (Camera, Mic, Canvas) — send and receive live video/audio over the WebRTC mesh