Real-time
socket-io

Socket.io

TypeScriptOpen SourceFree tierWebSocket

The most widely used real-time bidirectional event-based communication library. Works across browsers and Node.js with automatic fallbacks and built-in reconnection.

License

MIT

Language

TypeScript / JavaScript

84
Trust
Strong

Why Socket.io?

Building chat apps, collaborative tools, or live dashboards

You need bidirectional real-time communication with automatic reconnection

Your users may be behind proxies — Socket.io handles WebSocket fallbacks

Signal Breakdown

What drives the Trust Score

Weekly npm downloads
8.2M/wk
GitHub commits (90d)
45
GitHub stars
61k
Stack Overflow questions
120k
Community health
Very Active
Weighted Trust Score84 / 100

Download Trend

Last 12 months

Tradeoffs & Caveats

Know before you commit

You only need server-push (SSE is simpler)

High-scale managed solution — Pusher/Ably handle infra for you

You're using edge/serverless — WebSockets need persistent connections

Pricing

Free tier & paid plans

Free tier

Fully open source, self-hosted

Paid

N/A

Infrastructure costs are yours

Alternative Tools

Other options worth considering

pusher
Pusher81Strong

Managed WebSocket infrastructure as a service. Drop in real-time features (presence, channels, notifications) without managing your own WebSocket servers.

ably
Ably61Fair

Managed pub/sub real-time infrastructure with guaranteed message ordering, presence detection, and message history. Built for mission-critical applications that can't afford message loss.

Often Used Together

Complementary tools that pair well with Socket.io

nextjs

Next.js

Frontend & UI

98Excellent
View
redis

Redis

Database & Cache

93Excellent
View
express

Express.js

Backend Frameworks

87Strong
View
supabase

Supabase

Database & Cache

95Excellent
View
pusher

Pusher

Real-time

81Strong
View

Learning Resources

Docs, videos, tutorials, and courses

Get Started

Repository and installation options

View on GitHub

github.com/socketio/socket.io

npmnpm install socket.io

Quick Start

Copy and adapt to get going fast

// Server
import { createServer } from 'http';
import { Server } from 'socket.io';

const io = new Server(createServer(), { cors: { origin: '*' } });
io.on('connection', (socket) => {
  socket.on('chat', (msg: string) => io.emit('chat', msg));
});

// Client
import { io } from 'socket.io-client';
const socket = io('http://localhost:3001');
socket.emit('chat', 'Hello, world!');

Code Examples

Common usage patterns

Chat room

Simple broadcast chat with Socket.io

// Server: broadcast message to all clients
io.on('connection', (socket) => {
  socket.on('join', (room: string) => socket.join(room));
  socket.on('chat', ({ room, msg }: { room: string; msg: string }) => {
    io.to(room).emit('chat', { from: socket.id, msg });
  });
});

Presence tracking

Track who is online in a room

// Server
const onlineUsers = new Map<string, string>();

io.on('connection', (socket) => {
  socket.on('register', (username: string) => {
    onlineUsers.set(socket.id, username);
    io.emit('users', Array.from(onlineUsers.values()));
  });
  socket.on('disconnect', () => {
    onlineUsers.delete(socket.id);
    io.emit('users', Array.from(onlineUsers.values()));
  });
});

Community Notes

Real experiences from developers who've used this tool