Decentral Net: Module 3

Module 3

PeerJS & peer abstractions

PeerJS is a JavaScript library that simplifies WebRTC: you get a Peer object with an ID, methods to connect or listen, and data channels without hand-rolling every SDP exchange — as long as a compatible PeerServer (or cloud broker) handles signaling.

Peer IDs and discovery

A PeerJS client often receives a string peer id from the broker. To connect, another peer uses that id — so you still need an out-of-band way to share ids: QR codes, paste boxes, URLs with hash fragments, or a small directory service.

The broker does not need to see your payload if you use encrypted channels correctly — but it does see metadata (who connected to whom, timing). Threat-model that like any coordination server.

The broker is still a server

PeerJS’s “magic” is mostly packaging WebRTC signaling. You still depend on infrastructure for introduction and often for TURN. If the public PeerJS cloud disappears or rate-limits you, you run your own peer server or switch libraries.

For Coffee experiments: fine to prototype on shared brokers; for anything serious, plan self-hosted signaling + TURN credentials.

When PeerJS vs raw WebRTC

Next up

IPFS shifts the question from “which peer socket?” to “which content hash?” — still networking, but discovery and retrieval follow a different metaphor.