Tools & SDKs
React SDK
Embed Rhombus camera streams in React applications with the official SDK, featuring DASH buffered playback and real-time H.264 WebSocket players via WebCodecs.
On this page
- Install
- Quick start
- Buffered player (DASH)
- Stream quality
- Realtime player (WebSocket)
- Connection modes
- Stream quality
- LAN mode considerations
- Backend setup
- Token endpoint
- Override mode (proxy all requests)
- Props reference
- Shared props
- RhombusBufferedPlayer props
- RhombusRealtimePlayer props
- Troubleshooting
- Resources
The official @rhombussystems/react package provides drop-in React components for streaming Rhombus cameras. Two player modes are available:
RhombusBufferedPlayer— MPEG-DASH live streaming via Dash.js (buffered, reliable)RhombusRealtimePlayer— Low-latency H.264 over WebSocket via WebCodecs (near real-time)
Requires React 18+ and a backend endpoint that generates federated session tokens. Your Rhombus API key must never be exposed to the browser.
Install
npm install @rhombussystems/reactyarn add @rhombussystems/reactpnpm add @rhombussystems/reactPeer dependencies: react and react-dom >= 18. The dashjs library is included automatically for DASH playback.
Quick start
import { RhombusBufferedPlayer } from "@rhombussystems/react";
export function CameraView() {
return <RhombusBufferedPlayer cameraUuid="YOUR_CAMERA_UUID" />;
}This renders a DASH-based buffered video player. The component automatically:
- Requests a federated session token from your backend (
POST /api/federated-token) - Fetches media URIs from the Rhombus API
- Initializes Dash.js playback
Your backend must implement a POST /api/federated-token endpoint (or configure a custom path via the paths.federatedToken prop). See Backend Setup below.
Buffered player (DASH)
The RhombusBufferedPlayer streams MPEG-DASH live video with configurable quality levels.
import { RhombusBufferedPlayer } from "@rhombussystems/react";
export function BufferedCamera() {
return (
<RhombusBufferedPlayer
cameraUuid="YOUR_CAMERA_UUID"
bufferedStreamQuality="HIGH"
/>
);
}Stream quality
Control server-side downscaling with the bufferedStreamQuality prop:
| Value | Description |
|---|---|
"HIGH" | Full resolution (default) |
"MEDIUM" | Medium downscale |
"LOW" | Low resolution, lowest bandwidth |
Changing quality does not re-fetch the manifest or token — the Dash.js RequestModifier applies the change on the next segment request.
import { useState } from "react";
import {
RhombusBufferedPlayer,
type RhombusBufferedStreamQuality,
} from "@rhombussystems/react";
export function CameraWithQuality() {
const [quality, setQuality] = useState<RhombusBufferedStreamQuality>("HIGH");
return (
<>
<select
value={quality}
onChange={(e) => setQuality(e.target.value as RhombusBufferedStreamQuality)}
>
<option value="HIGH">High</option>
<option value="MEDIUM">Medium</option>
<option value="LOW">Low</option>
</select>
<RhombusBufferedPlayer
cameraUuid="YOUR_CAMERA_UUID"
bufferedStreamQuality={quality}
/>
</>
);
}Realtime player (WebSocket)
The RhombusRealtimePlayer decodes H.264 frames over WebSocket using the browser's WebCodecs API and renders to a <canvas>. This provides lower latency than DASH.
import { RhombusRealtimePlayer } from "@rhombussystems/react";
export function RealtimeCamera() {
return (
<RhombusRealtimePlayer
cameraUuid="YOUR_CAMERA_UUID"
connectionMode="wan"
/>
);
}Connection modes
| Mode | Description |
|---|---|
"wan" | Uses the WAN H.264 WebSocket URI with federated token auth appended to the URL |
"lan" | Uses the LAN H.264 WebSocket URI. Federated token auth is appended to the URL the same way as WAN (x-auth-scheme=federated-token and x-auth-ft query parameters) |
Stream quality
| Value | Description |
|---|---|
"HD" | Full resolution (default) |
"SD" | Lower resolution via /wsl path — changing this prop reconnects the WebSocket |
Browser compatibility: WebCodecs with H.264 decoding is supported in Chrome, Edge, and Safari 16.4+. Firefox support is limited.
LAN mode considerations
In LAN mode, the SDK appends the federated token to the WebSocket URL as query parameters (x-auth-scheme=federated-token and x-auth-ft), the same way it does for WAN. This works from any origin, including localhost.
The practical requirement for LAN mode is network reachability: the browser must be able to reach the camera/NVR host directly (routing, firewall, and HTTPS-vs-HTTP mixed-content rules all apply). See Streaming over LAN for how LAN authentication works and why devices accept only federated tokens.
SDK 1.0 and later authenticate LAN mode with URL query parameters, like WAN. The RFT cookie and the applyLanAuthCookie prop of pre-1.0 versions aren't part of the SDK; if an older guide uses them, upgrade and remove them.
Backend setup
The SDK requires a server-side endpoint to generate federated session tokens. Your Rhombus API key stays on the server — it is never sent to the browser.
Token endpoint
Your backend must expose a POST endpoint (default path: /api/federated-token):
const express = require("express");
const app = express();
app.use(express.json());
// The exact origin your pages are served from, such as https://app.example.com
const APP_ORIGIN = process.env.APP_ORIGIN;
app.post("/api/federated-token", async (req, res) => {
// At most 24 hours; 1 hour if the request doesn't say
const durationSec = Math.min(Number(req.body.durationSec) || 3600, 86400);
const response = await fetch(
"https://api2.rhombussystems.com/api/org/generateFederatedSessionToken",
{
method: "POST",
headers: {
"Content-Type": "application/json",
"x-auth-scheme": "api-token",
"x-auth-apikey": process.env.RHOMBUS_API_KEY,
},
body: JSON.stringify({ durationSec, domain: APP_ORIGIN }),
}
);
if (!response.ok) return res.status(502).json({ error: "Could not mint a token" });
// Return the whole response: the SDK reads expiresAtMs and renews the token before it expires
res.json(await response.json());
});from fastapi import FastAPI, Request
import httpx, os
app = FastAPI()
# The exact origin your pages are served from, such as https://app.example.com
APP_ORIGIN = os.environ["APP_ORIGIN"]
@app.post("/api/federated-token")
async def federated_token(request: Request):
body = await request.json()
# At most 24 hours; 1 hour if the request doesn't say
duration_sec = min(int(body.get("durationSec") or 3600), 86400)
async with httpx.AsyncClient() as client:
response = await client.post(
"https://api2.rhombussystems.com/api/org/generateFederatedSessionToken",
headers={
"Content-Type": "application/json",
"x-auth-scheme": "api-token",
"x-auth-apikey": os.environ["RHOMBUS_API_KEY"],
},
json={"durationSec": duration_sec, "domain": APP_ORIGIN},
)
response.raise_for_status()
# Return the whole response: the SDK reads expiresAtMs and renews the token before it expires
return response.json()// app/api/federated-token/route.ts
import { NextResponse } from "next/server";
// The exact origin your pages are served from, such as https://app.example.com
const APP_ORIGIN = process.env.APP_ORIGIN!;
export async function POST(request: Request) {
const body = await request.json();
// At most 24 hours; 1 hour if the request doesn't say
const durationSec = Math.min(Number(body.durationSec) || 3600, 86400);
const response = await fetch(
"https://api2.rhombussystems.com/api/org/generateFederatedSessionToken",
{
method: "POST",
headers: {
"Content-Type": "application/json",
"x-auth-scheme": "api-token",
"x-auth-apikey": process.env.RHOMBUS_API_KEY!,
},
body: JSON.stringify({ durationSec, domain: APP_ORIGIN }),
}
);
if (!response.ok) return NextResponse.json({ error: "Could not mint a token" }, { status: 502 });
// Return the whole response: the SDK reads expiresAtMs and renews the token before it expires
return NextResponse.json(await response.json());
}Set domain to your app's exact origin: an absolute origin with scheme, host and any non-default port, and no path, such as https://app.example.com (or http://localhost:5173 in development). The browser fetches media URIs from api2.rhombussystems.com directly, and without a domain that matches your app's origin those requests fail with CORS errors. Rhombus accepts a token with domain only on requests whose Origin (or, without one, Referer) matches it, and answers any other with 403 DOMAIN_NOT_ALLOWED. A value that isn't an absolute origin fails the mint with 400.
The SDK asks your endpoint for a lifetime (tokenDurationSec, 86400 by default) and fetches a new token shortly before the expiresAtMs your endpoint returns, so return the mint response unchanged. Rhombus caps federated tokens at 24 hours and uses one hour when durationSec is left out.
Override mode (proxy all requests)
If you prefer to keep all Rhombus traffic server-side (the browser never talks to Rhombus directly), use apiOverrideBaseUrl:
<RhombusBufferedPlayer
cameraUuid="YOUR_CAMERA_UUID"
apiOverrideBaseUrl="https://your-api.example.com"
/>In this mode, your backend must also expose a POST /api/media-uris endpoint that proxies to Rhombus's POST /camera/getMediaUris.
Props reference
Shared props
| Prop | Type | Default | Description |
|---|---|---|---|
cameraUuid | string | required | Camera UUID to stream |
apiOverrideBaseUrl | string | — | Route both token and media requests through your server |
rhombusApiBaseUrl | string | https://api2.rhombussystems.com/ | Rhombus API base URL (when not using override) |
paths.federatedToken | string | /api/ | Path to your token endpoint |
paths.mediaUris | string | /camera/ or /api/ | Path for media URI resolution |
federatedSessionToken | string | — | Skip token fetch; use this token directly |
tokenDurationSec | number | 86400 | Token lifetime, in seconds, the SDK requests from your token endpoint; at most 86400 |
headers | object | — | Extra headers merged into the token request |
getRequestHeaders | () | — | Dynamic headers for each request |
onError | (error: | — | Error callback |
RhombusBufferedPlayer props
| Prop | Type | Default | Description |
|---|---|---|---|
bufferedStreamQuality | "HIGH" | "MEDIUM" | "LOW" | "HIGH" | Server-side downscale level |
applyBufferedStreamQuality | boolean | true | Set false to disable quality parameter |
RhombusRealtimePlayer props
| Prop | Type | Default | Description |
|---|---|---|---|
connectionMode | "wan" | "lan" | required | WAN or LAN media URIs; both append the token as URL query parameters |
realtimeStreamQuality | "HD" | "SD" | "HD" | Stream resolution; changing reconnects the WebSocket |
Troubleshooting
404 on /api/federated-token
Your backend does not have a token endpoint at the expected path. Either implement POST /api/federated-token or set the paths.federatedToken prop to match your route.
CORS errors fetching media URIs
The federated token was generated without a domain matching your app's origin. Pass your app's exact origin (such as https://app.example.com) as the domain parameter when calling generateFederatedSessionToken on your backend.
403 DOMAIN_NOT_ALLOWED, or 401 after the page has been open a while
A 403 DOMAIN_NOT_ALLOWED means the page's origin isn't the token's domain (check scheme, host and port). A 401 means the token expired or was revoked: make sure your endpoint returns expiresAtMs so the SDK renews the token in time.
Realtime player shows nothing
Check browser compatibility — WebCodecs H.264 requires Chrome, Edge, or Safari 16.4+. Check the browser console for [RhombusRealtimePlayer] messages.
LAN mode not authenticating
LAN mode appends the federated token to the WebSocket URL as query parameters (the same as WAN), so it works from any origin including localhost. If LAN mode fails, confirm the browser can reach the camera/NVR host directly (routing, firewall, and HTTPS-vs-HTTP mixed-content rules). If the LAN host is unreachable from the browser, use connectionMode="wan" or proxy through your backend.
Resources
Package details and version history
Source code, examples, and issues
Low-level streaming implementation without the SDK
Custom Dash.js player implementation