@@ -29,36 +29,35 @@ on top of WebRTC:
2929- 🏭⚡ Runs server-side
3030- ⚛️🪝 React hooks
3131
32- You can see what people are building with Trystero [ here] ( https://github.com/jeremyckahn/awesome-trystero ) .
32+ You can see what people are building with Trystero
33+ [ here] ( https://github.com/jeremyckahn/awesome-trystero ) .
3334
3435---
3536
3637## Contents
3738
38- - [ ✨🤝✨ Trystero] ( #-trystero )
39- - [ Contents] ( #contents )
40- - [ How it works] ( #how-it-works )
41- - [ Get started] ( #get-started )
42- - [ Listen for events] ( #listen-for-events )
43- - [ Broadcast events] ( #broadcast-events )
44- - [ Audio and video] ( #audio-and-video )
45- - [ Advanced] ( #advanced )
46- - [ Binary metadata] ( #binary-metadata )
47- - [ Action promises] ( #action-promises )
48- - [ Progress updates] ( #progress-updates )
49- - [ Encryption] ( #encryption )
50- - [ React hooks] ( #react-hooks )
51- - [ Connection issues] ( #connection-issues )
52- - [ Running server-side (Node, Deno, Bun)] ( #running-server-side-node-deno-bun )
53- - [ Supabase setup] ( #supabase-setup )
54- - [ Firebase setup] ( #firebase-setup )
55- - [ API] ( #api )
56- - [ ` joinRoom(config, roomId, [onJoinError]) ` ] ( #joinroomconfig-roomid-onjoinerror )
57- - [ ` selfId ` ] ( #selfid )
58- - [ ` getRelaySockets() ` ] ( #getrelaysockets )
59- - [ ` getOccupants(config, roomId) ` ] ( #getoccupantsconfig-roomid )
60- - [ Strategy comparison] ( #strategy-comparison )
61- - [ How to choose] ( #how-to-choose )
39+ - [ How it works] ( #how-it-works )
40+ - [ Get started] ( #get-started )
41+ - [ Listen for events] ( #listen-for-events )
42+ - [ Broadcast events] ( #broadcast-events )
43+ - [ Audio and video] ( #audio-and-video )
44+ - [ Advanced] ( #advanced )
45+ - [ Binary metadata] ( #binary-metadata )
46+ - [ Action promises] ( #action-promises )
47+ - [ Progress updates] ( #progress-updates )
48+ - [ Encryption] ( #encryption )
49+ - [ React hooks] ( #react-hooks )
50+ - [ Connection issues] ( #connection-issues )
51+ - [ Running server-side (Node, Deno, Bun)] ( #running-server-side-node-deno-bun )
52+ - [ Supabase setup] ( #supabase-setup )
53+ - [ Firebase setup] ( #firebase-setup )
54+ - [ API] ( #api )
55+ - [ ` joinRoom(config, roomId, [onJoinError]) ` ] ( #joinroomconfig-roomid-onjoinerror )
56+ - [ ` selfId ` ] ( #selfid )
57+ - [ ` getRelaySockets() ` ] ( #getrelaysockets )
58+ - [ ` getOccupants(config, roomId) ` ] ( #getoccupantsconfig-roomid )
59+ - [ Strategy comparison] ( #strategy-comparison )
60+ - [ How to choose] ( #how-to-choose )
6261
6362---
6463
@@ -126,8 +125,8 @@ const room = joinRoom(config, 'yoyodyne')
126125```
127126
128127The first argument is a configuration object that requires an ` appId ` . This
129- should be a completely unique identifier for your app¹. The second argument
130- is the room ID.
128+ should be a completely unique identifier for your app¹. The second argument is
129+ the room ID.
131130
132131> Why rooms? Browsers can only handle a limited amount of WebRTC connections at
133132> a time so it's recommended to design your app such that users are divided into
@@ -241,8 +240,8 @@ room.onPeerLeave(peerId =>
241240
242241> Actions are smart and handle serialization and chunking for you behind the
243242> scenes. This means you can send very large files and whatever data you send
244- > will be received on the other side as the same type (a number as a number,
245- > a string as a string, an object as an object, binary as binary, etc.).
243+ > will be received on the other side as the same type (a number as a number, a
244+ > string as a string, an object as an object, binary as binary, etc.).
246245
247246## Audio and video
248247
@@ -403,8 +402,8 @@ means.
403402Trystero functions are idempotent so they already work out of the box as React
404403hooks.
405404
406- Here's a simple example component where each peer syncs their favorite
407- color to everyone else:
405+ Here's a simple example component where each peer syncs their favorite color to
406+ everyone else:
408407
409408``` jsx
410409import {joinRoom } from ' trystero'
@@ -486,23 +485,24 @@ export const useRoom = (roomConfig, roomId) => {
486485WebRTC is powerful but some networks simply don't allow direct P2P connections
487486using it. If you find that certain user pairings aren't working in Trystero,
488487you're likely encountering an issue at the network provider level. To solve this
489- you can configure a TURN server which will act as a proxy layer for peers
490- that aren't able to connect directly to one another.
488+ you can configure a TURN server which will act as a proxy layer for peers that
489+ aren't able to connect directly to one another.
491490
4924911 . If you can, confirm that the issue is specific to particular network
493492 conditions (e.g. user with ISP X cannot connect to a user with ISP Y). If
494493 other user pairings are working (like those between two browsers on the same
495494 machine), this likely confirms that Trystero is working correctly.
4964952 . Sign up for a TURN service or host your own. There are various hosted TURN
497- services you can find online like [ Cloudflare] ( https://developers.cloudflare.com/calls/turn/ )
498- (which offers a free tier with 1,000 GB traffic per month) or
496+ services you can find online like
497+ [ Cloudflare] ( https://developers.cloudflare.com/calls/turn/ ) (which offers a
498+ free tier with 1,000 GB traffic per month) or
499499 [ Open Relay] ( https://www.metered.ca/stun-turn ) . You can also host an open
500500 source TURN server like [ coturn] ( https://github.com/coturn/coturn ) ,
501501 [ Pion TURN] ( https://github.com/pion/turn ) ,
502502 [ Violet] ( https://github.com/paullouisageneau/violet ) , or
503- [ eturnal] ( https://github.com/processone/eturnal ) . Keep in mind data will
504- only go through the TURN server for peers that can't directly connect and
505- will still be end-to-end encrypted.
503+ [ eturnal] ( https://github.com/processone/eturnal ) . Keep in mind data will only
504+ go through the TURN server for peers that can't directly connect and will
505+ still be end-to-end encrypted.
5065063 . Once you have a TURN server, configure Trystero with it like this:
507507 ``` js
508508 const room = joinRoom (
@@ -549,9 +549,8 @@ To use the Supabase strategy:
549549
5505501 . Create a [ Supabase] ( https://supabase.com ) project or use an existing one
5515512 . On the dashboard, go to Project Settings -> API
552- 3 . Copy the Project URL and set that as the ` appId ` in the Trystero config,
553- copy the ` anon public ` API key and set it as ` supabaseKey ` in the Trystero
554- config
552+ 3 . Copy the Project URL and set that as the ` appId ` in the Trystero config, copy
553+ the ` anon public ` API key and set it as ` supabaseKey ` in the Trystero config
555554
556555### Firebase setup
557556
@@ -599,9 +598,9 @@ the same namespace will return the same room instance.
599598- ` config ` - Configuration object containing the following keys:
600599 - ` appId ` - ** (required)** A unique string identifying your app. When using
601600 Supabase, this should be set to your project URL (see
602- [ Supabase setup instructions] ( #supabase-setup ) ). If using
603- Firebase, this should be the ` databaseURL ` from your Firebase config (also
604- see ` firebaseApp ` below for an alternative way of configuring the Firebase
601+ [ Supabase setup instructions] ( #supabase-setup ) ). If using Firebase, this
602+ should be the ` databaseURL ` from your Firebase config (also see
603+ ` firebaseApp ` below for an alternative way of configuring the Firebase
605604 strategy).
606605
607606 - ` password ` - ** (optional)** A string to encrypt session descriptions via
@@ -651,15 +650,11 @@ the same namespace will return the same room instance.
651650 default). Changing this is useful if you want to run multiple apps using the
652651 same database and don't want to worry about namespace collisions.
653652
654- - ` libp2pConfig ` - ** (optional, 🪐 IPFS only)**
655- [ ` Libp2pOptions ` ] ( https://libp2p.github.io/js-libp2p/types/libp2p.index.Libp2pOptions.html )
656- where you can specify a list of static peers for bootstrapping.
657-
658653 - ` manualRelayReconnection ` - ** (optional, 🐦 Nostr and 🌊 BitTorrent only)**
659- Boolean (default: ` false ` ) that when set to ` true ` disables
660- automatically pausing and resuming reconnection attempts when the browser
661- goes offline and comes back online. This is useful if you want to manage
662- this behavior yourself.
654+ Boolean (default: ` false ` ) that when set to ` true ` disables automatically
655+ pausing and resuming reconnection attempts when the browser goes offline and
656+ comes back online. This is useful if you want to manage this behavior
657+ yourself.
663658
664659- ` roomId ` - A string to namespace peers and events within a room.
665660
@@ -678,8 +673,8 @@ Returns an object with the following methods:
678673
679674 Returns a map of
680675 [ ` RTCPeerConnection ` ] ( https://developer.mozilla.org/en-US/docs/Web/API/RTCPeerConnection ) s
681- for the peers present in room (not including the local user). The keys of
682- this object are the respective peers' IDs.
676+ for the peers present in room (not including the local user). The keys of this
677+ object are the respective peers' IDs.
683678
684679- ### ` addStream(stream, [targetPeers], [metadata]) `
685680
@@ -803,8 +798,8 @@ Returns an object with the following methods:
803798
804799 Returns an array of three functions:
805800 1 . #### Sender
806- - Sends data to peers and returns a promise that resolves when all
807- target peers are finished receiving data.
801+ - Sends data to peers and returns a promise that resolves when all target
802+ peers are finished receiving data.
808803
809804 - ` (data, [targetPeers], [metadata], [onProgress]) `
810805 - ` data ` - Any value to send (primitive, object, binary). Serialization
@@ -908,14 +903,14 @@ console.log(trystero.getRelaySockets())
908903### ` pauseRelayReconnection() `
909904
910905** (🐦 Nostr, 🌊 BitTorrent only)** Normally Trystero will try to automatically
911- reconnect to relay sockets unless ` manualRelayReconnection: true ` is set in
912- the room config. Calling this function stops relay reconnection attempts until
906+ reconnect to relay sockets unless ` manualRelayReconnection: true ` is set in the
907+ room config. Calling this function stops relay reconnection attempts until
913908` resumeRelayReconnection() ` is called.
914909
915910### ` resumeRelayReconnection() `
916911
917- ** (🐦 Nostr, 🌊 BitTorrent, only)** Allows relay reconnection attempts to resume.
918- (See ` pauseRelayReconnection() ` above).
912+ ** (🐦 Nostr, 🌊 BitTorrent, only)** Allows relay reconnection attempts to
913+ resume. (See ` pauseRelayReconnection() ` above).
919914
920915### ` getOccupants(config, roomId) `
921916
0 commit comments