---
url: https://doc.moq.dev/lib/js/room.md
description: Headless multi-participant rooms over MoQ
---

# @moq/room

[![npm](https://img.shields.io/npm/v/@moq/room)](https://www.npmjs.com/package/@moq/room)

A room is a path prefix. There is no service and no storage: joining is minting
a moq-auth token rooted at that prefix and dialing the relay. Participants are
discovered from the announce stream. Identity is the path before `camera.hang` /
`screen.hang`. Each participant publishes `{identity}/camera.hang` (camera + mic, hd/sd)
and `{identity}/screen.hang` (screenshare).

```ts
import { Local, Room } from "@moq/room";
import { Connection, Path } from "@moq/net";
import { claims } from "@moq/room";
import { Key } from "@moq/auth";

const token = await Key.sign(key, claims("meet/demo", "alice"));
const connection = new Connection({
    url: new URL(`https://relay.example.com/meet/demo?jwt=${token}`),
    enabled: true,
});

const local = new Local({
	connection,
    identity: Path.from("alice"),
    user: { name: "Alice" },
});
local.enabled.set(true);
local.cameraEnabled.set(true);

const room = new Room({ connection, identity: Path.from("alice") });
```

On a public prefix, skip the token and dial that path directly. The conferencing
demo at [`demo/web`](https://github.com/moq-dev/moq/tree/main/demo/web) (`meet.html`)
does that under `anon/meet/{room}`.

Each remote member owns a `Watch.Player`. Display video with
`member.canvas.set(canvas)` and unmute with `member.muted.set(false)`, or use
`member.player` for the full pipeline.

hang.live should depend on this package for the roster, local publish, remote
watch, and `hang/user.json` + `hang/preview.json`. Location stays an app-defined
catalog extension. The JSON window chat track (`Chat`) uses `@moq/json` Window;
hang.live's JSON chat (`hang/chat.json`) stays an extension of the same catalog
`hang` section.

The native twin is [`moq-room`](/lib/rs/moq-room).

See the package [README](https://github.com/moq-dev/moq/blob/main/js/room/README.md)
for the full API.
