peer.js (Github: peers/peerjs, License: MIT) provides a complete, configurable, and easy-to-use peer-to-peer API built on top of WebRTC, supporting both data channels and media streams. peer.js wraps the browser’s WebRTC implementation to provide a complete, configurable, and easy-to-use peer-to-peer connection API. Equipped with nothing but an ID, a peer can create a P2P data or media stream connection to a remote peer.

npm install peerjs

To broker connections, peer.js connects to a PeerServer (free hosted or host your own). Note that no peer-to-peer data goes through the server – the server acts only as connection broker.


var Peer = require('peerjs').Peer;

// You can pick your own id or omit the id if you want to get a random one from the server.
var peer = new Peer('pick-an-id', { key: 'myapikey' });


var conn = peer.connect('another-peers-id');
conn.on('open', function() {


peer.on('connection', function(conn) {
  conn.on('data', function(data) {
    // Will print 'hi!'

Checkout the awesome API docs and take it out for a spin. You can create a video chat with just a few lines of code. Have you done any peer-to-peer stuff?