Skip to content

PeerJS

A JavaScript library that lets browsers connect directly to each other for data and video/audio calls.

Stars
13.5k
Forks
1.5k
Licence
MIT
Language
TypeScript
Last update
8 months ago
Type
Library

What it is

PeerJS is a JavaScript library that wraps WebRTC, the browser technology for direct connections between users, in a simpler API. It lets web apps send data or start audio and video calls between peers identified by IDs. The README says it needs a PeerServer to help peers find each other, which is a separate project.

  • Send text messages between two browser tabs using a peer ID
  • Start a video call from one browser and answer it in another
  • Build a small peer-to-peer data channel feature in a web app

Great for

  • Web developers adding real-time chat or file-style data exchange between browsers
  • Developers building simple video or audio call features in a web app
  • Teams who want a TypeScript-based WebRTC wrapper with a small API
  • Prototypes that connect two browsers without building their own signaling layer

Not ideal for

  • People who need a finished app with no coding, since this is a library for developers
  • Projects needing guaranteed connections across all networks, because the README does not describe NAT traversal or relay fallback
  • Users needing support for very old browsers, since the README says only listed versions are officially supported
Step-by-step guide: how to use PeerJSInstall, first run, examples, tips and FAQs

How to get it

  1. 1

    Install with a package manager

    You'll need: Node.js or a bundler such as Parcel or Webpack (README does not specify versions)

    Install with npm

    npm install peerjs

    Install with yarn

    yarn add peerjs
  2. 2

    Run it

    • Install the package with npm or yarn
    • Import Peer from "peerjs"
    • Create a peer with new Peer("pick-an-id") or omit the id to get a random one
    • Connect to another peer ID with peer.connect() and send data once the connection opens
  3. 3

    Get the most out of it

    • Use the official API docs at peerjs.com/docs for full options
    • Run a PeerServer (peers/peerjs-server) if you need your own signaling server, as the live example does
    • Check the changelog when upgrading, since the README says browser support changes will be breaking
    • Use Firefox 102+ if you need CBOR or MessagePack serialization

Downloads

Strengths

  • Small, focused API: create a peer, connect, send data, or call
  • Tested against current Chrome, Edge, Firefox, and Safari versions per the README
  • MIT licensed with a documentation site and changelog

Trade-offs

  • Requires a PeerServer for peers to find each other; the README points to a separate project for it
  • The README notes a Parcel-related console warning when used with Webpack, described as non-critical
  • Browser support is limited to listed versions; others are unsupported

How it compares

ProjectStarsTypeLevelUpdatedBest for
peerjs (this)13.5kLibraryintermediate8 months agoWeb developers adding real-time chat or file-style data exchange between browsers
socket.io63.2kLibraryintermediate1 months agoDevelopers building live chat or real-time notifications in JavaScript or TypeScript
webtorrent31.5kLibraryintermediate5 days agoDevelopers who want to add torrent downloading or streaming to a JavaScript web or Node.js app
feathers15.3kLibraryintermediate5 days agoJavaScript or TypeScript developers building a web API
webtorrent-desktop10.1kAppbeginner6 days agoPeople who want to stream torrent video without waiting for a full download
monaco-editor46.9kLibraryintermediate6 days agoWeb developers adding a code editing box to a browser app

Stats synced from GitHub. The assessment above was drafted with AI from the project's README on 2026-10-29 and may miss recent changes — check the README before relying on a command. MIT licence: free to use, modify and distribute, including commercially, as long as you keep the copyright notice.