Skip to main content
The Red5 Pro Conference SDK is a JavaScript toolkit for building multi-party video conferencing applications on Red5 Cloud and Red5 Pro. It manages room lifecycle, WHIP/WHEP media publishing and subscribing, WebRTC statistics monitoring, and interactive features including virtual backgrounds, local recording, screen sharing, and PubNub-powered chat — all from a single ConferenceClient object.

Installation

npm install red5pro-conference-sdk

Key concepts

  • Room — a named session identified by a roomId. Multiple users join the same room to exchange audio and video.
  • Participant — a user in the room, identified by a userId. Each participant can publish audio/video (role: publisher) or receive only (role: subscriber).
  • Media tracks — participants publish their local MediaStream via WHIP, and subscribe to each other’s streams via WHEP. You receive a MediaStream for each subscribed participant to attach to a <video> element.

Joining a room

1

Create a ConferenceClient

Pass your server details and optional PubNub keys for chat.
import { ConferenceClient, ConferenceEvents } from 'red5pro-conference-sdk';

const client = new ConferenceClient({
  host: 'your-red5-pro-host',
  nodeGroup: 'your-node-group',
  iceServers: [{ urls: 'stun:stun.l.google.com:19302' }],
  pubnubPublishKey: 'your-pubnub-publish-key',
  pubnubSubscribeKey: 'your-pubnub-subscribe-key',
});
2

Subscribe to new participants

Listen for NEW_PARTICIPANT and subscribe automatically so you receive their video as soon as they join.
client.addEventListener(ConferenceEvents.NEW_PARTICIPANT, async (e) => {
  const user = e.detail;
  try {
    const info = await client.subscribe(user);
    if (info?.mediaStream) {
      const videoEl = document.createElement('video');
      videoEl.srcObject = info.mediaStream;
      videoEl.autoplay = true;
      document.getElementById('participants').appendChild(videoEl);
    }
  } catch (err) {
    console.error('Subscribe failed', err);
  }
});
3

Acquire local media and join

const localStream = await navigator.mediaDevices.getUserMedia({
  video: true,
  audio: true,
});

await client.join(
  'my-room-id',   // roomId
  'user-123',     // userId
  'auth-token',   // token from your backend
  'publisher',    // role: 'publisher' or 'subscriber'
  localStream,    // MediaStream
  true,           // videoEnabled
  true            // audioEnabled
);

console.log('Joined room successfully');
4

Leave the room

await client.leave();

Media controls

Mute and unmute your local audio and video without leaving the room.
// Mute/unmute audio
await client.muteAudio();
await client.unmuteAudio();

// Mute/unmute video
await client.muteVideo();
await client.unmuteVideo();

// Listen for state changes
client.addEventListener(ConferenceEvents.AUDIO_MUTED, () => {
  console.log('Audio is muted');
});
Switch device without dropping the connection:
// Switch to a different camera
await client.switchVideoDeviceWithTrackReplacement(newCameraDeviceId);

// Switch to a different microphone
await client.switchAudioDeviceWithTrackReplacement(newMicDeviceId);

Screen sharing

// Start sharing your screen
await client.startScreenShare({
  includeAudio: true,
  metaData: { type: 'presentation' },
});

// Stop sharing
await client.stopScreenShare();

Virtual backgrounds

Virtual backgrounds use @mediapipe/selfie_segmentation to replace or blur the area behind your camera feed.
1

Initialize the background processor

await client.initializeVirtualBackground();
2

Apply a background

// Blur background
await client.enableVirtualBackground('blur', { blurAmount: 10 });

// Image replacement
await client.enableVirtualBackground('image', {
  imageUrl: 'path/to/background.jpg',
});
3

Remove the background

await client.disableVirtualBackground();
Available background types:
TypeDescription
VirtualBackgroundTypes.NONENo background processing
VirtualBackgroundTypes.BLURStrong blur
VirtualBackgroundTypes.SLIGHT_BLURLight blur
VirtualBackgroundTypes.IMAGEImage replacement
VirtualBackgroundTypes.COLORSolid color replacement

Local recording

Record participant streams directly in the browser. The recording is stored locally and downloaded as a ZIP file.
// Download the local recording
await client.downloadLocalRecording('my-conference-2026-05-21');

// Or get a ZIP blob to handle yourself
const zipBlob = await client.generateLocalRecordingZip();

Chat

Send and receive text messages within the room using PubNub. Pass your PubNub keys in the ConferenceClient config.
// Listen for incoming messages
client.addEventListener(ConferenceEvents.CHAT_MESSAGE, (e) => {
  const message = e.detail;
  console.log('New message:', message.text);
});

// Send a message
client.sendChatMessage('Hello everyone!');

Configuration reference

PropertyTypeDefaultDescription
hoststringRequiredRed5 Pro server address
nodeGroupstringundefinedTarget node group for scaling
iceServersRTCIceServer[]undefinedSTUN/TURN server configurations
reconnectionEnabledbooleanfalseEnable automatic reconnection
maxVideoBitrateKbpsnumberundefinedMaximum video bitrate for publishing
statsPollingIntervalnumberundefinedWebRTC stats polling interval in ms
pubnubPublishKeystringundefinedPubNub key for chat
pubnubSubscribeKeystringundefinedPubNub key for chat
enableNoiseCancellationbooleanfalseEnable RNNoise noise suppression

API reference highlights

MethodReturnsDescription
join(roomId, userId, token, role, mediaStream, videoEnabled, audioEnabled)Promise<boolean>Join a conference room
leave()Promise<void>Leave the conference room
getRoomUsers()ObjectGet all current room users
getIsJoined()booleantrue if currently in a room
getIsPublishing()booleantrue if currently publishing
MethodReturnsDescription
subscribe(user: User)Promise<{ subscriber, user, mediaStream }>Subscribe to a participant’s stream
unsubscribe(userId: string)Promise<void>Stop subscribing to a participant
EventDescription
USER_PUBLISHEDLocal client published successfully
NEW_PARTICIPANTA new participant joined the room
PARTICIPANT_DISCONNECTEDA participant left the room
SUBSCRIBE_SUCCESSSuccessfully subscribed to a participant
ROOM_STATE_UPDATERoom users, roles, or states changed
CHAT_MESSAGEA chat message was received
ISSUES_DETECTEDNetwork or WebRTC issues detected
VIDEO_MUTED / AUDIO_MUTEDVideo or audio muted successfully
Use the Backend SDK to generate the token parameter you pass to client.join(). This keeps your master credentials on the server and gives you control over user roles and token expiration.