like-webrtc is a JavaScript library for creating peer-to-peer WebRTC connections in browsers, Node.js, and React Native without building signaling and discovery from scratch. It provides a familiar server-and-client model: a server listens under a cryptographic public-key address, and another peer connects using that address. Applications can exchange data channels, audio or video tracks, and transceivers. The library supplies signaling, default STUN and TURN servers, and automatic exchange and negotiation of WebRTC connection details. Its signaling service uses a WebSocket RPC protocol and Noise encryption, while public keys serve as shareable peer identities rather than IP addresses.
For groups, peers can announce servers under shared topics, look up announced peers, or join a topic to discover and connect with others; joining also announces a listening peer. Connections can be restricted with a public-key firewall, and topic-based connections retry after disconnection on an increasing schedule. The API also supports stable identities generated from a seed, direct announcement management, and duplex-stream wrappers for data channels or WebSockets. Announcements can outlast an abrupt disconnect, so a lookup may return an offline peer. The package aims to make browser-based peer-to-peer applications practical, with a live demo modeled on a chat service. Its proposed extensions include encrypted relay messages, small-scale media forwarding, easier TURN deployment, and reusable tools for audio, video, and screen sharing.
Summary generated by AI from the linked article. hn.today is not affiliated with Hacker News or Y Combinator.