---
title: "Realtime"
description: "Add shared rooms for messages, presence, and WebRTC setup."
canonical_url: "https://extraorbital.dev/docs/resources/realtime"
last_updated: "2026-11-26"
---

# Realtime

> Add shared rooms for messages, presence, and WebRTC setup.

```bash title="Run in your project folder"
npx extraorbital add realtime
```

Create browser room tokens on your server. Keep API and TURN keys private.

Run the command → read the credentials in .env → connect your app through the SDK or API.

## Limits

| Limit | Free · Prototype | Paid |
| --- | --- | --- |
| Realtime resources | 10 | No plan count cap |
| Requests | From the $5.00 account allowance | Usage billed |
| Bandwidth | From the $5.00 account allowance | $0.08 / GB of TURN relay |
| Spend | Idle connections are free | Idle connections are free |

Free allowances are shared across the account. Provider limits still apply on paid plans.

<span id="join-a-room-from-your-server" />

## Use it

```js
import { Realtime } from "@extraorbital/realtime";

const realtime = Realtime.fromEnv(process.env);
const room = await realtime.join("lobby", { peer: "server" });
room.on("message", (message) => console.log(message.from, message.data));
await room.send({ hello: "world" });
```

For browsers, create a room token on your server and send it to the client. Keep API and TURN keys server-side. The relay URL is public.

## Environment variables

The CLI writes these to `.env` or an existing `.env.local`.

| Variable | Purpose |
| --- | --- |
| `REALTIME_URL` | Relay endpoint for server clients |
| `NEXT_PUBLIC_REALTIME_URL` | Public relay endpoint for browser clients |
| `REALTIME_API_KEY` | Private key used to create room tokens |
| `REALTIME_TURN_KEY` | Private key for TURN relay access |

## Specifics

### Browser access

Create short-lived room join tokens on the server and pass them to the browser. The relay URL is public; the API and TURN keys are not.

<span id="usage" />

## Pricing

| Usage | Paid rate |
| --- | --- |
| Requests | $0.05 / M messages, $2.00 / M connections and API calls |
| Bandwidth | $0.08 / GB of TURN relay |
| Spend | Idle connections are free |

See [plans and billing](/pricing) for subscription fees and billing terms.

---

More for agents: [Sitemap](https://extraorbital.dev/sitemap.md) · [llms.txt](https://extraorbital.dev/llms.txt) · [agents.md](https://extraorbital.dev/agents.md)
