← All open source projects

Socket.IO

socketio/socket.io

Socket.IO is a library for bidirectional real-time communication between clients and servers.

Forks 10,154
Author socketio
Language TypeScript
License MIT
Synced 2026-06-27

What it is

Socket.IO is a library for bidirectional real-time communication. It helps clients and servers exchange events without constant polling: chat, notifications, collaborative editing, game state, and live dashboards.

It addresses a web problem: plain HTTP is good for request-response, but not for server-initiated updates.

How the event model works

Socket.IO is built around events. A client connects, listens for events, sends messages, and the server broadcasts updates to connected clients.

It is not just raw WebSocket. It adds reconnection, rooms, namespaces, acknowledgements, and transport fallbacks.

Minimal server

This example shows the core idea: accept a connection, listen for `chat message`, and broadcast it.

Language: JavaScript
import { Server } from 'socket.io';

const io = new Server(3000, {
  cors: { origin: 'https://example.com' }
});

io.on('connection', (socket) => {
  socket.on('chat message', (message) => {
    io.emit('chat message', message);
  });
});

What is inside

The repository contains the Socket.IO server, TypeScript code, tests, and protocol infrastructure. Client pieces and adapters live in the broader ecosystem.

Compatibility matters: Socket.IO is used beyond browsers, with clients for different languages and environments.

Strengths

The main strength is a simple event model. Teams can think in business events instead of low-level WebSocket frames.

The ecosystem is mature, with documentation, adapters, and scaling patterns for common needs.

Limits

Socket.IO needs careful state architecture when servers scale horizontally: adapters, rooms, event delivery, and reconnect behavior matter.

For simple one-way streams, Server-Sent Events or raw WebSocket may be enough. Socket.IO is useful when the extra bidirectional layer is needed.