Getting Started with Realtime Messaging
Pick the path that matches your stack and what you're building.
Pick your path
Using JavaScript or TypeScript?
Use the @metered-ca/realtime SDK. It handles framing, reconnect, perfect-negotiation WebRTC, and auto-applies the TURN credentials the signalling server injects. Five lines to connect-subscribe-publish, ~30 lines for a working video call.
npm install @metered-ca/realtime
→ JavaScript SDK — Getting Started
Using any other stack?
Speak the wire protocol directly — Go, Python, Java, Swift, Kotlin, Rust, Unity, anything that can open a WebSocket and sign HS256 JWTs.
→ Introduction → Quickstart — connect, subscribe, and publish in under 30 lines (with Browser and Node tabs)
The SDK and raw-WS clients speak the same protocol byte-for-byte. An SDK client and a raw-WS client can be peers in the same channel.
Just want a copy-paste demo?
The Single-File HTML Demo runs in one HTML file with no build, no backend, no JWT minting. Demonstrates presence, chat, WebRTC video, and auto-injected TURN in ~200 lines. Save the file, replace the pk_live_ key, open in two browser tabs.
Pick by what you're building
| You're building… | Read this first |
|---|---|
| WebRTC video call with the SDK | JS SDK: WebRTC Video Call |
| WebRTC from a static site (no backend) | JS SDK: WebRTC No Backend |
| WebRTC from a non-JS stack | Raw-WS WebRTC Signalling |
| Chat / classroom / livestream chat | JS SDK: Presence & Chat |
| AI agent communication | JS SDK: AI Agent Communication |
| IoT telemetry | JS SDK: IoT Telemetry |
| Migrating from simple-peer or PeerJS | Migration from simple-peer · from PeerJS |
Going to production
Two pages worth reading before you ship, regardless of which path you took above:
- Reconnect Best Practices — handling drops, refreshing tokens, surfacing "reconnecting" UI. The single most-skipped doc that bites everyone in production.
- Limits & Quotas — message size cap, channel cap, per-connection rate limit, plan quotas. Bookmark when sizing a deployment.
If something doesn't work the way you expect, the Troubleshooting guide is symptom-first ("messages aren't arriving", "video stays black", "stuck in reconnecting") rather than code-first.
Reference material
- Wire Format — every message type the server speaks
- REST API — mint tokens, list peers, kick peers, query usage
- Authentication — pk_ vs JWT, choosing between them
- Errors & Codes (SDK) — every error class with
instanceofexamples