Trystero – Serverless peer-to-peer multiplayer for the web Trystero, a serverless peer-to-peer multiplayer library for the web, lets any static site become a live multiplayer app via a single `npm i trystero` install, with no accounts, API keys, or infrastructure required. Rooms provide ECDSA P-256-derived persistent user identities verified during the WebRTC handshake, signed per-user and shared state that syncs to late joiners, an optional `roles()` plugin for verified admins and peer bans, and live audio/video, with handshakes encrypted using AES-256-GCM and PBKDF2-SHA256 key derivation when a `password` is set. An experimental `scale()` plugin switches rooms past `maxDirectPeers + 1` peers to a multi-hop gossip overlay for messages and state while promoting media and large binary transfers to direct links. Trystero turns any static site into a live multiplayer app. Import the library, join a room by name, and browsers discover each other instantly. No accounts, no API keys, no infra. Perfect for coding agents. npm i trystero Rooms include verified user identities, synced per-user and shared state, host permissions, RPC, chunked file transfers, and live audio and video. Ship a multiplayer game or collaborative tool from GitHub Pages, Neocities, or a single HTML file. The cursors moving across this page belong to other visitors connected through Trystero. Open this in two browsers and move your pointer. You can also skip a bundler and import directly from https://esm.run/trystero in a module script. Multiplayer apps usually track two kinds of state: per-user values each participant owns names, cursors, ready flags and shared room values for the group a game board, round timer, or playback queue . Writes apply locally right away, coalesce rapid updates on the wire, carry the author's signature, and sync to late joiners even after the original writer leaves. Both primitives match React's useSyncExternalStore contract directly. Every participant gets a persistent userId derived from an ECDSA keypair and verified during the WebRTC handshake, with no login flow or auth server. Refreshing or opening another tab keeps the same identity, and identity config supports ephemeral per-tab keys or keys imported from your app. Combine password and maxUsers for private, seat-limited rooms such as a two-player match or four-seat lobby. Plain peer-to-peer rooms treat every participant equally, which breaks down when any client can open DevTools and overwrite game state. The optional roles plugin adds verified room admins, custom roles like 'dj' or 'moderator' , role-gated state and actions, and peer bans. Peers verify every write against the author's signature and role certificate, dropping unauthorized edits on arrival. Create named channels with room.makeAction for ephemeral events, request/response calls, and binary transfers. Send strings, JSON, Blob s, File s, or typed arrays; Trystero handles framing, chunking, backpressure, metadata, and transfer progress. Large files use the same channel API as small messages and stream directly between peers without intermediate storage. Send microphone audio, webcam video, screen captures, canvas.captureStream , or Web Audio output to the room or to specific users. Tag streams with metadata to distinguish camera feeds from screen shares, and swap tracks mid-call with replaceTrack . Standard WebRTC rooms connect every browser directly to every other, which suits small groups and low-latency matches. For larger cooperative sessions, add the experimental scale plugin. Small rooms stay in a direct mesh. Past maxDirectPeers + 1 peers, browsers form a multi-hop gossip overlay for messages and state while promoting media streams and large binary transfers to direct links on demand. Trystero also runs in server and CLI runtimes with a WebRTC polyfill. Run a game bot, bridge local hardware, or keep a passive: true peer online to cache signed room state while browser tabs are closed. Identity, state, and signaling encryption rely on Web Crypto primitives verified directly by peers. Handshakes are encrypted with AES-256-GCM before reaching any relay. Default rooms derive the key from appId and roomId ; setting password derives it via PBKDF2-SHA256 so outsiders cannot decrypt offers or join. Every userId and peerId derives from an ECDSA P-256 public key bound to the WebRTC DTLS certificate fingerprint RFC 8827 , preventing peer spoofing and relay man-in-the-middle attacks. State updates and role certificates carry ECDSA signatures and Hybrid Logical Clock timestamps, so any peer or late joiner can verify authorship and ordering independently. Architecture notes and walkthroughs for building peer-to-peer web apps.