Skip to main content
Open Source · MIT Licensed

WebRTC without
the boilerplate

PeerJS abstracts complex data, audio, and video connections into a straightforward API.

npm install peerjsready in seconds
app.js
import { Peer } from "peerjs";

// Create a peer
const peer = new Peer();

peer.on("open", (id) => {
console.log("My peer ID:", id);
});

// Connect to a remote peer
const conn = peer.connect("remote-peer-id");

conn.on("open", () => {
conn.send("Hello, peer! 👋");
});

// Receive data
peer.on("connection", (conn) => {
conn.on("data", (data) => {
console.log("Received:", data);
});
});
Features

Everything you need for P2P

PeerJS wraps the browser's WebRTC implementation to provide a complete, configurable, and easy-to-use peer-to-peer connection API.

Runs Everywhere

Build once and connect seamlessly across every major browser. Beta support is also available for Node.js, Bun, and Deno.

Video & Audio Calls

Stream media between peers. Build video chats, screen sharing, and real-time audio apps.

Simple API

A clean, event-driven API that wraps the complexity of WebRTC. Connect peers in under 10 lines of code.

Send Anything

Transfer strings, JSON, ArrayBuffers, and Blobs. Send files, game state, or any serializable data.

Secure by Default

All WebRTC connections are encrypted with DTLS. Your data never passes through a central server.

Configurable

Configure ICE servers, debug levels, and serialization formats. Use our free cloud server or host your own PeerServer.

Nonprofit

Backed by sponsors and community

PeerJS is made possible thanks to the generous support of our sponsors and community.

Community Backers

PeerJS contributors on OpenCollective

Start building peer-to-peer

Join thousands of developers building real-time apps with PeerJS.