Repolode
dmotz

dmotz/trystero

A JavaScript library for building multiplayer web apps where browsers connect peer-to-peer over WebRTC without running your own server.

Stars
2,796
Forks
161
Open issues
7
Last commit
yesterday

What is it?

Trystero handles the matchmaking step that WebRTC normally requires. Browsers join a room by ID and discover each other through a signaling channel such as Nostr (the default), BitTorrent, MQTT, IPFS, Supabase, Firebase, or a self-hosted WebSocket relay. Once connected, application data travels directly between peers and is end-to-end encrypted, so the signaling medium only carries connection details.

On top of WebRTC it provides rooms and broadcasting, typed actions for sending messages, automatic serialization and chunking of large payloads, progress events, request/response calls, and support for audio and video streams. The same API works in the browser and on Node, Bun, and Deno, and React hooks are included. Switching strategies only requires changing the imported package.

Trystero is written in TypeScript and distributed on npm under the trystero package name, with strategy-specific packages under the @trystero-p2p scope.

Key features

  • 01Serverless peer discovery over Nostr, BitTorrent, MQTT, IPFS, Supabase, Firebase, or a WebSocket relay
  • 02Rooms with broadcasting and typed custom actions for peer messages
  • 03Automatic serialization and chunking of large data, with progress events
  • 04Audio and video stream sharing between peers
  • 05Optional password-based session encryption and TURN server support
  • 06Runs in browsers and server-side on Node, Bun, and Deno

Use cases

  • Building a browser-based multiplayer game without maintaining a backend
  • Creating a private audio or video chat room between users
  • Transferring files directly between browsers in a web app
  • Syncing shared state such as cursors or form data among collaborators

Quick start

  1. 1

    Install Trystero with npm

    npm i trystero
  2. 2

    Import joinRoom in your code

  3. 3

    Join a room with a unique appId and a room ID

Things to know

  • Peer discovery depends on a third-party strategy network such as Nostr, MQTT, or Supabase, so your app relies on that network being available.
  • Browsers can only handle a limited number of WebRTC connections, so rooms should be kept small.
  • Received files must fit in browser memory, and each room defaults to a 256 MiB receive budget.

Topics

FAQ

What is trystero?
A JavaScript library for building multiplayer web apps where browsers connect peer-to-peer over WebRTC without running your own server. Trystero handles the matchmaking step that WebRTC normally requires. Browsers join a room by ID and discover each other through a signaling channel such as Nostr (the default), BitTorrent, MQTT, IPFS, Supabase, Firebase, or a self-hosted WebSocket relay. Once connected, application data travels directly between peers and is end-to-end encrypted, so the signaling medium only carries connection details.
Is trystero free to use? What license does it have?
trystero is open source under the MIT license. Check the license terms before using it in commercial products.
Is trystero still maintained?
Actively maintained. The last commit to trystero was on Oct 18, 2026.
What can I use trystero for?
Building a browser-based multiplayer game without maintaining a backend Creating a private audio or video chat room between users Transferring files directly between browsers in a web app Syncing shared state such as cursors or form data among collaborators
How do I install trystero?
Install Trystero with npm: npm i trystero Import joinRoom in your code Join a room with a unique appId and a room ID
Where can I get trystero?
The source code and installation instructions are on GitHub: https://github.com/dmotz/trystero

Summary generated by AI from the project's README. GitHub stats refresh daily.

Related projects