Tiempo Real ⭐ 58k stars
Comunicación bidireccional en tiempo real entre cliente y servidor (WebSockets + polling).
frontend-desarrollo (regla: solo catálogo de las 66 · versiones por ERR/MEJ)
Instalación: npm i socket.io socket.io-client
import { Server } from 'socket.io';
const io = new Server(3000);
io.on('connection', (s) => s.emit('hola', 'mundo'));
Dos casos de uso comunes implementados con esta librería.
Servidor que reenvía mensajes a todos los clientes.
import { Server } from 'socket.io';
const io = new Server(3000);
io.on('connection', (socket) => {
socket.on('mensaje', (txt) => io.emit('mensaje', { de: socket.id, txt }));
});Separa la comunicación por sala.
import { Server } from 'socket.io';
const io = new Server(3000);
io.on('connection', (socket) => {
socket.on('unirse', (sala) => socket.join(sala));
socket.on('msg', (sala, txt) => io.to(sala).emit('msg', txt));
});| Categoría | Tiempo Real |
|---|---|
| Stars (GitHub) | ⭐ 58k |
| Sitio oficial | https://socket.io/ |
| GitHub | https://github.com/socketio/socket.io |
| Instalación | npm i socket.io socket.io-client |
| Relacionadas | WebSockets API · SockJS · uWebSockets |
C:\Users\TUF\Documents\librerías\local\ antes de descargar.
Volver al índice de los 66 estudios.