Implement real-time bidirectional communication between clients and servers for instant data synchronization and live updates.
When to Use
Chat and messaging applications
Live dashboards and analytics
Collaborative editing (Google Docs-style)
Real-time notifications
Live sports scores or stock tickers
Multiplayer games
Live auctions or bidding systems
IoT device monitoring
Real-time location tracking
Quick Start
Minimal working example:
// server.ts
import WebSocket, { WebSocketServer } from "ws";
import { createServer } from "http";
interface Message {
type: "join" | "message" | "leave" | "typing";
userId: string;
username: string;
content?: string;
timestamp: number;
}
interface Client {
ws: WebSocket;
userId: string;
username: string;
roomId: string;
}
class ChatServer {
private wss: WebSocketServer;
private clients: Map<string, Client> = new Map();
private rooms: Map<string, Set<string>> = new Map();
constructor(port: number) {
// ... (see reference guides for full implementation)
Reference Guides
Detailed implementations in the references/ directory:
Guide
Contents
WebSocket Server (Node.js)
WebSocket Server (Node.js)
WebSocket Client (React)
WebSocket Client (React)
Server-Sent Events (SSE)
Server-Sent Events (SSE)
Socket.IO (Production-Ready)
Socket.IO (Production-Ready)
Best Practices
✅ DO
Implement reconnection logic with exponential backoff
Use heartbeat/ping-pong to detect dead connections
Validate and sanitize all messages
Implement authentication and authorization
Handle connection limits and rate limiting
Use compression for large payloads
Implement proper error handling
Monitor connection health
Use rooms/channels for targeted messaging
Implement graceful shutdown
❌ DON'T
Send sensitive data without encryption
Keep connections open indefinitely without cleanup
Broadcast to all users when targeted messaging suffices
Ignore connection state management
Send large payloads frequently
Skip message validation
Forget about mobile/unstable connections
Ignore scaling considerations
Converted and distributed by TomeVault — claim your Tome and manage your conversions.
1---2name: aj-geddes-useful-ai-prompts-real-time-features3description: Real-Time Features4---56# Real-Time Features78## Table of Contents910- [Overview](#overview)11- [When to Use](#when-to-use)12- [Quick Start](#quick-start)13- [Reference Guides](#reference-guides)14- [Best Practices](#best-practices)1516## Overview1718Implement real-time bidirectional communication between clients and servers for instant data synchronization and live updates.1920## When to Use2122- Chat and messaging applications23- Live dashboards and analytics24- Collaborative editing (Google Docs-style)25- Real-time notifications26- Live sports scores or stock tickers27- Multiplayer games28- Live auctions or bidding systems29- IoT device monitoring30- Real-time location tracking3132## Quick Start3334Minimal working example:3536```typescript37// server.ts38import WebSocket, { WebSocketServer } from "ws";39import { createServer } from "http";4041interface Message {42 type: "join" | "message" | "leave" | "typing";43 userId: string;44 username: string;45 content?: string;46 timestamp: number;47}4849interface Client {50 ws: WebSocket;51 userId: string;52 username: string;53 roomId: string;54}5556class ChatServer {57 private wss: WebSocketServer;58 private clients: Map<string, Client> = new Map();59 private rooms: Map<string, Set<string>> = new Map();6061 constructor(port: number) {62// ... (see reference guides for full implementation)63```6465## Reference Guides6667Detailed implementations in the `references/` directory:6869| Guide | Contents |70|---|---|71| [WebSocket Server (Node.js)](references/websocket-server-nodejs.md) | WebSocket Server (Node.js) |72| [WebSocket Client (React)](references/websocket-client-react.md) | WebSocket Client (React) |73| [Server-Sent Events (SSE)](references/server-sent-events-sse.md) | Server-Sent Events (SSE) |74| [Socket.IO (Production-Ready)](references/socketio-production-ready.md) | Socket.IO (Production-Ready) |7576## Best Practices7778### ✅ DO7980- Implement reconnection logic with exponential backoff81- Use heartbeat/ping-pong to detect dead connections82- Validate and sanitize all messages83- Implement authentication and authorization84- Handle connection limits and rate limiting85- Use compression for large payloads86- Implement proper error handling87- Monitor connection health88- Use rooms/channels for targeted messaging89- Implement graceful shutdown9091### ❌ DON'T9293- Send sensitive data without encryption94- Keep connections open indefinitely without cleanup95- Broadcast to all users when targeted messaging suffices96- Ignore connection state management97- Send large payloads frequently98- Skip message validation99- Forget about mobile/unstable connections100- Ignore scaling considerations101102---103> Converted and distributed by [TomeVault](https://tomevault.io/claim/aj-geddes) — claim your Tome and manage your conversions.104<!-- tomevault:4.0:skill_md:2026-04-11 -->
Run npx skillmds@latest add tomevault-io/aj-geddes-useful-ai-prompts-real-time-features in your terminal (requires Node.js), paste this page's agent-chat prompt into Claude, Cursor, or any MCP-connected agent, or download the SKILL.md file and copy it into your agent's skills directory.
Real-Time Features It is listed under Coding & Dev Tools on SkillMD.
This skill has not completed SkillMD's automated safety review yet. Independent scanners report: SkillSpector: PASS, Skill Scanner: PASS. SkillMD never runs a skill's scripts for you; review the SKILL.md before installing.
This skill is tagged as working with Claude Code, Claude.ai, OpenAI Codex. SKILL.md is an open format, so most agents that read a skills directory can load it too.
Yes. Installing skills from SkillMD is free, and the skill stays under its author's original license.
tomevault-io (@tomevault-io) published this skill. Their other Agent Skills are listed on their SkillMD profile.