Docs
Choose how peers discover each other
Signaling lets peers find each other and exchange connection details. Your app’s messages and media travel over WebRTC, separately from the signaling service.
Default package
The trystero package uses public Nostr relays. You can start
without creating an account or deploying a relay.
import {joinRoom} from 'trystero'
const room = joinRoom({appId: 'com.example.myapp'}, 'room-id')Choose another strategy
Install the strategy package you want, then change the import. All strategies share the room and action API; some need additional config. Peers that should discover each other need to use the same strategy.
npm i @trystero-p2p/mqttimport {joinRoom} from '@trystero-p2p/mqtt'
const room = joinRoom({appId: 'com.example.myapp'}, 'room-id')| Strategy | Package | Setup |
|---|---|---|
| Nostr | trystero | Public relays by default |
| MQTT | @trystero-p2p/mqtt | Public brokers by default |
| BitTorrent | @trystero-p2p/torrent | Public trackers by default |
| Supabase | @trystero-p2p/supabase | Project URL and public API key |
| Firebase | @trystero-p2p/firebase | Realtime Database URL and database rules |
| IPFS | @trystero-p2p/ipfs | IPFS discovery network |
| WebSocket relay | @trystero-p2p/ws-relay | Relay you host; URLs required |
Public relays are convenient for getting started. For a shipped app, choose infrastructure whose availability and usage policies you can depend on. A signaling relay and a TURN server solve different problems: switching strategies does not replace TURN for restricted networks.
Use a Supabase or Firebase project
Supabase uses your project URL as appId and its anon public
key as relayConfig.supabaseKey. Firebase uses your Realtime
Database URL as appId. Configure database access for its
signaling path, or pass an existing app as
relayConfig.firebaseApp. See the
Firebase setup instructions.
import {joinRoom} from '@trystero-p2p/supabase'
const room = joinRoom(
{
appId: 'https://your-project.supabase.co',
relayConfig: {supabaseKey: 'your-anon-public-key'}
},
'room-id'
)Use your own WebSocket relay
The WebSocket relay package includes a server you can run. This strategy
requires relayConfig.urls; it has no default public relay.
Terminate TLS at your server or proxy to expose a wss://
endpoint. App data still travels over WebRTC.
import {joinRoom} from '@trystero-p2p/ws-relay'
const room = joinRoom(
{
appId: 'com.example.myapp',
relayConfig: {
urls: ['wss://relay.example.com']
}
},
'room-id'
)
Nostr, MQTT, and BitTorrent also accept relayConfig.urls.
With default endpoints, relayConfig.redundancy controls
how many are used. With custom URLs, the entire list is used instead.