RelayrtcDocs
Get started
Documentation
React SDK

React SDK

Build your call interface with RelayRTC providers, hooks and media controls.

On this page

Install

Shell
pnpm add @relayrtc/react @relayrtc/client

See 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

React
'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

HookPurpose
useRoomRoom, connection state, errors, join and leave.
useParticipantsLocal and remote participant list.
useLocalParticipantLocal identity, media controls and metadata.
useTracksFilter remote publications.
useMediaTrackBind local or remote media to an element and track playback.
useLocalMediaCamera, microphone and screen snapshots.
useMessagesLocal message history and sending.
useConnectionQualityRoom 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.

HookPurpose
useBroadcastRun/output status and asynchronous controls
useRecordingCapture state, finalization and recording indicators
useScheduledBroadcastEvent status, countdown and schedule commands
useRestreamSourceExternal source health and controls
useClipHighlight rendering and publication
useMixerRequested and observed scene revisions
useDvrPlaybackSeekable ranges, rewind and Go live
useStreamGuests and useGuestSessionStage 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.