React SDK
Build your call interface with RelayRTC providers, hooks and media controls.
On this page
Install
pnpm add @relayrtc/react @relayrtc/clientSee installation for package requirements.
Requirements
Use React 18.3.1 or 19, a supported browser, a signaling URL and a participant token from your server. Use HTTPS outside localhost.
Wrap your call in RelayProvider and RelayRoom. Hooks read the nearest provider.
Connect a room
'use client'
import { RelayProvider, RelayRoom } from '@relayrtc/react'
export function Call({ token, signalingUrl }: { token: string; signalingUrl: string }) {
return (
<RelayProvider signalingUrl={signalingUrl}>
<RelayRoom token={token}>
<div>Your call interface</div>
</RelayRoom>
</RelayProvider>
)
}The SDK handles room state and media. You choose the layout, controls and participant tiles.
Hooks
| Hook | Purpose |
|---|---|
| useRoom | Room, connection state, errors, join and leave. |
| useParticipants | Local and remote participant list. |
| useLocalParticipant | Local identity, media controls and metadata. |
| useTracks | Filter remote publications. |
| useMediaTrack | Bind local or remote media to an element and track playback. |
| useLocalMedia | Camera, microphone and screen snapshots. |
| useMessages | Local message history and sending. |
| useConnectionQuality | Room and participant network quality. |
Components
Use MediaLoader to show loading. The SDK does not include a prebuilt Zoom-style call layout.
Server work
Create rooms, issue tokens and administer participants with the Node SDK or REST API. Keep secret API keys out of this package.
Streaming playback
BroadcastPlayer and useStreamPlayback provide private HTTP viewing independently of the RTC provider/room. Supply application-authorized metadata and grant callbacks. Use compatible React/browser builds as described in installation.
| Hook | Purpose |
|---|---|
| useBroadcast | Run/output status and asynchronous controls |
| useRecording | Capture state, finalization and recording indicators |
| useScheduledBroadcast | Event status, countdown and schedule commands |
| useRestreamSource | External source health and controls |
| useClip | Highlight rendering and publication |
| useMixer | Requested and observed scene revisions |
| useDvrPlayback | Seekable ranges, rewind and Go live |
| useStreamGuests and useGuestSession | Stage moderation and caller-bound RTC participation |
These hooks use application callbacks rather than a management key in the browser. The status hooks do not require an RTC provider. useDvrPlayback observes an already attached media element; useGuestSession owns its separate guest room. Use provider hooks for the room owned by that provider.
Room roles and effective permissions
useRoomAccess observes the local effective capability snapshot and exposes participant-authorized access reads/updates. See room roles for host assignment, moderator boundaries and live screen-share revocation.