Docs

Getting started with Trystero

Connect peers in a room, give your messages a name, and send data or media. These docs cover Trystero 0.26.0. The full API reference lives in the library README.

Start with a room

A room groups connected peers. Each peer creates the same named actions to exchange messages. In this chat sketch, the message input, button, and addMessage() are part of your UI.

import {joinRoom} from 'trystero'

const room = joinRoom({appId: 'com.example.chat'}, 'lobby')
const chat = room.makeAction('chat')

chat.onMessage = (message, {peerId}) => {
  addMessage(peerId, message)
}

sendButton.onclick = () => {
  chat.send({text: messageInput.value})
}

Getting started

Install Trystero, join a room, and send your first peer-to-peer message.

Actions

Send messages, ask for replies, and approve incoming transfers.

Media streams

Send camera, microphone, and screen-share streams between browsers.

Signaling strategies

Choose Nostr, MQTT, BitTorrent, Supabase, Firebase, IPFS, or your own relay.

Connections and access

Handle connection failures, configure TURN, and control who joins.

Upgrading to 0.26

Update older APIs and account for the new receive budget and wire format.

WebRTC without a signaling server

Learn how Trystero handles discovery without a custom signaling backend.

WebRTC vs WebSockets

Pick the right realtime transport for your data, media, and server model.