How it works

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.

01 · Room

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. Three peers: p1 (a laptop, marked as you), p2 (a phone) and p3 (a laptop). With three peers, every peer links to every other. ROOM · K3X9Q p1 · you p2 p3

A room of three peers, p1, p2 and p3, each linked directly to both others.

Rooms, peers and keys

02 · Join

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.

A peer joining through the introducer, in three frames: p5 calls join, the introducer introduces it to p2 and p4, then p5 links directly to them while the introducer stays in the background. 1. p5 calls join(); the introducer, outside the room, admits it (a dotted line from the introducer to p5). 2. The introducer introduces p5 to p2 and p4 (dotted lines to all three); it carries only the setup, never the data. 3. p5 is linked directly to p2 and p4; the dotted lines are gone and the introducer stays in the background. introducer p1 p2 p3 p4 p5 · joining 1 · p5 calls join() the introducer admits it introducer p1 p2 p3 p4 p5 · joining 2 · introduced to p2, p4 it carries only the setup introducer p1 p2 p3 p4 p5 3 · linked directly no data via the introducer
In three steps
  1. p5 calls join(). The introducer, outside the room, admits it.
  2. The introducer introduces p5 to p2 and p4. It carries only the setup, never the data.
  3. p5 links directly to p2 and p4. The introducer stays in the background.
03 · Mesh

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.

A room of eleven peers, laptops and phones, each linked directly to two to six others. The introducer sits outside the room. One link, between p7 and p9, goes through the relay outside the room, which sees only ciphertext. A message is on its way from p11 to p7. Peers p1 to p11 in one room, p7 marked as you. Each has a few direct links, none links to everyone. The introducer, outside the room, is idle. The relay, outside the room, carries the one link between p7 and p9. A message travels on the link from p11 to p7. ROOM · K3X9Q introducernot in the data path relayciphertext only p1 p2 p3 p4 p5 p6 p7 · you p8 p9 p10 p11

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.

How messages travel

04 · Relay

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.

Two peers, p7 and p9, whose direct link is blocked by their networks. Their link goes through the relay, outside the room, which passes on ciphertext it cannot read. p7 (you) and p9 are in the room with p3 and p8, which link to them directly. Between p7 and p9 the direct link is blocked (a cross). A dashed link runs from p7 down to the relay, outside the room, and back up to p9. The relay sees only ciphertext. ROOM · K3X9Q no direct link relayciphertext only p7 · you p9 p3 p8

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.

05 · Phones

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.

A phone goes away and comes back, in three frames: p5 is linked to p2 and p4, then its page is hidden and its links drop, then it rejoins with the same id and its links return. 1. p5, a phone, is linked directly to p2 and p4. 2. p5's page is hidden: it says goodbye, is drawn hollow and labelled away, and its links drop; the other peers route around it. 3. The page returns: p5 rejoins through the introducer (a dotted line) with the same id, and its links to p2 and p4 return. introducer p1 p2 p3 p4 p5 1 · p5 here linked to p2 and p4 introducer p1 p2 p3 p4 p5 · away 2 · page hidden: away it says goodbye; links drop introducer p1 p2 p3 p4 p5 · back 3 · back, same id rejoined via the introducer
In three steps
  1. p5, a phone, is linked directly to p2 and p4.
  2. p5's page is hidden. It says goodbye and is away, its links dropped. The others route around it.
  3. The page returns. p5 rejoins through the introducer with the same id, and its links return.

Lifecycle

06 · Sending

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.

Two ways to send in the same room. Left, a broadcast from p1 reaches every peer hop by hop through other peers, and every member can read it. Right, a send from p1 to p6 is sealed end to end; p3 and p7 forward it but cannot read it. Left, broadcast(data): p1 sends to p2 and p3 (hop 1); p2 forwards to p4 and p5, p3 to p7 (hop 2); p4 forwards to p6 (hop 3). Every member can read a broadcast. Right, send(p6, data): the message goes p1 to p3 to p7 to p6, sealed with a lock; it is on its last hop. p3 and p7 forward it but cannot read or change it. broadcast(data) 1 1 2 2 2 3 p1 p2 p3 p4 p5 p6 p7 hop by hop, through peers; every member can read it send(p6, data) 1 2 3 p1 p2 p3 p4 p5 p6 p7 sealed end to end; p3, p7 forward, can't read
Two messages
  1. broadcast(data) from p1: p2 and p3 get it first, p4, p5 and p7 next, p6 last. Every member can read it.
  2. 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 and sendReliable compared
broadcastsendsendReliable
Toeveryone in the roomone peerone peer
Deliverybest effortbest effortretransmitted until acknowledged
Ordernone promisednone promisedin order, per peer
Size≤ 1,052 bytes≤ 1,052 bytes≤ 64 KiB
Sealednoyesyes
Use forfrequent state everyone needsfrequent state for one peermessages that must arrive

Choosing how to send

Not jsflow

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.

Is jsflow right for your app?

Waitlist

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.