How jsflow works. Introduced once, then browser to browser.
Browsers in a room talk directly over WebRTC. Our servers introduce them, and relay encrypted traffic only when a network blocks a direct link.
A room is a name. It exists while someone is in it.
Your page joins a room by name, with your app's publishable key. Rooms belong to your app, and each peer gets an id that is unique among the peers in the room at that time.
A room of three peers, p1, p2 and p3, each linked directly to both others.
The introducer. Never in the data path.
Your page calls join(). Our service introduces it to peers in the room, then stays in the background, with a light connection open for new arrivals and returns.
- p5 calls
join(). The introducer, outside the room, admits it. - The introducer introduces p5 to p2 and p4. It carries only the setup, never the data.
- p5 links directly to p2 and p4. The introducer stays in the background.
A mesh, not a hub. Messages hop browser to browser.
Each browser links to about 6 others, 4 on phones, not to everyone. A message may pass through other peers on its way. That keeps a 30-peer room cheap for every browser.
Eleven peers in one room, p7 marked as you. Each has a few direct links; none links to everyone. The introducer and the relay stand outside the room. A message travels from p11 to p7.
The relay, only when needed. It sees only ciphertext.
Strict NATs and some corporate networks block direct links. Then the link goes through our relay. It needs nothing from you, and it passes on data it cannot read.
p7 and p9 cannot link directly. Their link runs through the relay, outside the room, which passes on ciphertext it cannot read. p3 and p8 link to both directly.
Away, and back. With the same id.
Phones freeze hidden pages. When a page hides, jsflow says goodbye, so the others route around it at once. When it returns, it rejoins by itself, usually within about a second. Desktop Safari does the same; desktop Chrome and Firefox stay connected.
- p5, a phone, is linked directly to p2 and p4.
- p5's page is hidden. It says goodbye and is away, its links dropped. The others route around it.
- The page returns. p5 rejoins through the introducer with the same id, and its links return.
Three ways to send. Choose per message.
broadcast reaches everyone, and every member can read it. send and sendReliable go to one peer, sealed end to end: the peers that forward them cannot read or change them.
broadcast(data)from p1: p2 and p3 get it first, p4, p5 and p7 next, p6 last. Every member can read it.send(p6, data)from p1: it goes p1, p3, p7, p6, sealed end to end. p3 and p7 forward it but cannot read or change it.
broadcast | send | sendReliable | |
|---|---|---|---|
| To | everyone in the room | one peer | one peer |
| Delivery | best effort | best effort | retransmitted until acknowledged |
| Order | none promised | none promised | in order, per peer |
| Size | ≤ 1,052 bytes | ≤ 1,052 bytes | ≤ 64 KiB |
| Sealed | no | yes | yes |
| Use for | frequent state everyone needs | frequent state for one peer | messages that must arrive |
What jsflow is not. Know before you build.
jsflow carries small, frequent messages between 2 and 50 people in a room. Some things need something else, or your own server beside it.
No media.
jsflow carries data, not audio or video tracks.
No storage.
Nothing is kept. A message reaches the peers in the room when it is sent; late joiners need state from you.
No authority.
Peers are equals and can lie. Anything that must be fair or secret needs your own server to decide it.
Not rooms of hundreds.
It is built and tested for up to 50 peers a room.
In early access, by invitation. Join the waitlist.
We invite people from the waitlist in small groups, and write when it is your turn. Only your email address is required.