socket.io
node.js realtime framework server
Raw WebSockets require you to handle reconnection, event multiplexing, room management, binary data, and fallback for environments that don't support WebSockets. Socket.IO was built to make real-time bidirectional communication reliable across browsers, mobile clients, and servers without managing any of that yourself.
Socket.IO is an event emitter over the network. On the server: io.on('connection', socket => socket.on('message', data => io.emit('message', data))). On the client: socket.on('message', data => ...) and socket.emit('message', data). Both sides emit and listen to named events. Rooms let you broadcast to subsets of clients.
Installation
// with npm
npm install socket.io
// with yarn
yarn add socket.ioUse it when
Use Socket.IO for chat applications, live collaboration, real-time dashboards, multiplayer games, or any feature where the server needs to push updates to clients. The automatic reconnection and room system make it production-ready out of the box.
Skip it when
Socket.IO's abstraction layer adds overhead โ if you're communicating between services where you control both ends, raw WebSockets or Server-Sent Events (for one-way) are lighter. For very high throughput (millions of concurrent connections), the overhead of Socket.IO's protocol becomes meaningful.
Ready to explore the full API?
See every class, function, and relationship in an interactive graph.