๐ WebRTC
On the web, WebRTC is commonly used for peer-to-peer real-time audio or video streams and calls. It can also be used for games via data channels. The main difference between WebSocket and WebRTC is that WebSocket uses TCP and sends series of messages in blocking order, whereas WebRTC uses UDP and sends data in a non-blocking way with potential messages (or โpacketsโ) being lost. In the case of an authoritative server sending regular updates of a game state, we donโt need all messages to arrive in order, we only need the latest state. You might be fine with WebSocket, but if you need the lowest latency possible for multiplayer games (for a fast-paced game like an FPS for instance), WebRTC is a better fit. Here is a good introduction to game networking.
It seems like the only library offering a simple client-server socket.io-like setup is Geckos.io1k160/w. I only tried the example and it worked great. Geckos.io uses node-datachannel1906k/w under the hood, so you might want to look into this if you need a more custom setup. Check out this video comparison of WebSocket and WebRTC by the creator of Geckos.io.
There is also node-webrtc3k9k/w but I was not able to try it due to a missing file during installation, and web-udp6010/w5y years.
For peer-to-peer WebRTC, there is PeerJS12k24k/w and its PeerServer signaling server, or SimplePeer7k37k/w2y years and the related signaling server repository.