# Rooms, peers and keys

> The vocabulary: app, key, room and peer id.

## App and key

Your **app** has a publishable key (`pk_…`) and a list of allowed origins. The key is meant to be in your page source. It identifies your app and is no secret, and the service also checks the page's origin.

## Room

A room is a name you choose: `[A-Za-z0-9_-]`, 1 to 64 characters. Rooms belong to your app: another app's room with the same name is a different room. A room exists while someone is in it.

**Anyone who knows your key and a room name can join that room** (from an allowed origin), so use names that are hard to guess. See [security and privacy](https://jsflow.com/docs/guides/security-and-privacy.md).

> **Diagram: Three peers in one room: with three, every peer links to every other.** Three peers: p1 (a laptop, marked as you), p2 (a phone) and p3 (a laptop). With three peers, every peer links to every other.

## Peer id

The service gives each `join()` an integer id, unique in the room. A page reload or a new `join()` gets a new id. If your app has users, use join tickets: your server signs one for each user, and `room.user(peerId)` then gives every peer's user id, vouched for by the service. Without tickets, map ids to users yourself: send `room.id` to your server after joining.

## The mesh

Each browser keeps direct links to a few others, about 6 (4 on phones), not to everyone, and messages are forwarded hop by hop. That keeps a 30-peer room cheap for every browser. See [how messages travel](https://jsflow.com/docs/concepts/how-messages-travel.md).

Source: https://jsflow.com/docs/concepts/rooms-peers-keys/
