realtime

Implements WebSocket servers with rooms, presence, diff sync, and Redis scaling.

1|Updated Aug 17, 2026
One-click install
npx skills add https://github.com/NalinDalal/skillset --skill realtime-nalindalal
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: realtime
Source: https://github.com/NalinDalal/skillset/tree/main/skills/backend/realtime
Command: npx skills add https://github.com/NalinDalal/skillset --skill realtime-nalindalal

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires redis, uuid.

What problem does it solve? Building collaborative features like live cursors, chat, and multiplayer rooms requires handling connection lifecycles, message protocols, reconnection, and horizontal scaling, which is error-prone to implement from scratch. ## Core Features & Use Cases - WebSocket Server Setup: Bun native WebSocket server with authentication middleware, heartbeat, and connection lifecycle handlers. - Rooms, Presence & Diff Sync: RoomManager for membership and broadcasting, presence tracking with cursor positions, and diff-based synchronization for collaborative editing. - Scaling & Reconnection: Redis pub/sub adapter for multi-instance broadcasting and client-side reconnection with exponential backoff. - Use Case: You are building a collaborative whiteboard. Use this Skill to set up the WebSocket server, broadcast shape diffs and cursor updates to room members, and scale across instances with Redis. ## Quick Start Ask the agent to build a real-time chat or collaborative editing backend with WebSocket rooms, presence, and reconnection handling using this realtime skill.

Frequently Asked Questions about realtime

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I build a WebSocket server with Bun?▼

Use Bun's native serve API with a fetch handler that upgrades HTTP requests to WebSocket and a websocket object defining open, message, close, and drain handlers. Connection data like the authenticated user is attached via server.upgrade and accessed through ws.data.

How to implement rooms and presence in a WebSocket chat app?▼

Maintain a RoomManager with maps of connections and rooms, where each room tracks members with roles and join timestamps. Broadcast MEMBER_JOINED and MEMBER_LEFT events to room participants and track cursor positions per connection for presence.

How do I scale WebSocket servers across multiple instances?▼

Use a Redis pub/sub adapter where each server instance publishes room messages to channels like room:{roomId} and subscribes to receive broadcasts from other instances. Local broadcast still happens in-process while Redis fans out cross-instance messages.

How should WebSocket clients handle reconnection?▼

Implement exponential backoff starting at 1 second, doubling per attempt up to a maximum of 10 retries. On reconnect, send a RE_AUTH message with a fresh token and request FULL_STATE to restore room state lost during disconnection.

How do I authenticate WebSocket connections securely?▼

Issue short-lived WS tokens from an authenticated HTTP endpoint, then pass the token as a query parameter during the upgrade request. Verify the token in middleware before calling server.upgrade and reject with 401 if invalid or expired.