
Websocket Implementation
This is a production-ready WebSocket setup using Socket.IO with Redis pub/sub for horizontal scaling. It covers authentication middleware, room-based messaging, connection management, and includes both server and client implementations plus a React hook. The code handles reconnection logic, message queuing when offline, and provides monitoring endpoints for tracking active connections. What I like here is the scaling guidance table that tells you exactly when to add Redis (10K+ connections) versus staying single-server. It's opinionated about real concerns like rate limiting and not storing unlimited messages in memory, which saves you from learning those lessons the hard way in production.
- skills.sh installs
- 440
- GitHub stars
- 248
- last updated
- Aug 21, 2026
Install
$ npx -y skills add secondsky/claude-skills --skill websocket-implementation --agent claude-codeInstalls into .claude/skills of the current project.
Files
WebSocket Implementation
Build scalable real-time communication systems with proper connection management.
Server Implementation (Socket.IO)
const { Server } = require('socket.io');
const { createAdapter } = require('@socket.io/redis-adapter');
const { createClient } = require('redis');
const io = new Server(server, {
cors: { origin: process.env.CLIENT_URL, credentials: true }
});
// Redis adapter for horizontal scaling
const pubClient = createClient({ url: process.env.REDIS_URL });
const subClient = pubClient.duplicate();
Promise.all([pubClient.connect(), subClient.connect()]).then(() => {
io.adapter(createAdapter(pubClient, subClient));
});
// Connection management
const users = new Map();
io.use((socket, next) => {
const token = socket.handshake.auth.token;
try {
socket.user = verifyToken(token);
next();
} catch (err) {
next(new Error('Authentication failed'));
}
});
io.on('connection', (socket) => {
users.set(socket.user.id, socket.id);
console.log(`User ${socket.user.id} connected`);
socket.on('join-room', (roomId) => {
socket.join(roomId);
socket.to(roomId).emit('user-joined', socket.user);
});
Sponsors
Details
- Repository
- github.com/secondsky/claude-skills
- Category
- Backend & APIs
- First seen
- Jun 3, 2026
More from secondsky/claude-skills
All 146- Mobile App Debugging439
- Root Cause Tracing438
- App Store Deployment437
- Database Schema Design437
- Recommendation Engine437
- Seo Keyword Cluster Builder437
- Bun Sveltekit436
- Push Notification Setup436
- Drizzle Orm D1435
- Api Response Optimization434
- Api Pagination433
- Api Filtering Sorting432
- Defense In Depth Validation430
- Session Management427
- Ultracite426
- Nuxt Production425
- Api Gateway Configuration422
- Oauth Implementation422
- Nuxt Ui V4421
- Health Check Endpoints420
- Cloudflare D1416
- Api Changelog Versioning415
- Dependency Upgrade415
- Idempotency Handling415