React Native SDK API Reference
Complete API reference for the BaxCloud React Native SDK
Platform-Specific Notes
The React Native SDK API is identical to the React SDK, but with platform-specific considerations for mobile development.
Key Differences:
- Platform-specific rendering: Use React Native components (View, Text, TouchableOpacity) instead of HTML elements
- Permissions: Request camera/microphone permissions before connecting
- Native modules: Some features may require native module setup
- Lifecycle management: Handle app state changes (background/foreground)
Required Permissions
iOS (Info.plist):
- NSCameraUsageDescription
- NSMicrophoneUsageDescription
Android (AndroidManifest.xml):
- android.permission.CAMERA
- android.permission.RECORD_AUDIO
Permissions Example:
1import { PermissionsAndroid, Platform } from 'react-native';
2import { request, PERMISSIONS, RESULTS } from 'react-native-permissions';
3
4async function requestPermissions() {
5 if (Platform.OS === 'android') {
6 const granted = await PermissionsAndroid.requestMultiple([
7 PermissionsAndroid.PERMISSIONS.CAMERA,
8 PermissionsAndroid.PERMISSIONS.RECORD_AUDIO,
9 ]);
10
11 return (
12 granted['android.permission.CAMERA'] === PermissionsAndroid.RESULTS.GRANTED &&
13 granted['android.permission.RECORD_AUDIO'] === PermissionsAndroid.RESULTS.GRANTED
14 );
15 } else {
16 const cameraStatus = await request(PERMISSIONS.IOS.CAMERA);
17 const micStatus = await request(PERMISSIONS.IOS.MICROPHONE);
18
19 return (
20 cameraStatus === RESULTS.GRANTED &&
21 micStatus === RESULTS.GRANTED
22 );
23 }
24}Table of Contents
BaxCloudClient
Constructor
Initialize the BaxCloud client
new BaxCloudClient(config: BaxCloudConfig)Parameters
config.projectId(string) - Your BaxCloud project IDconfig.apiKey(string) - Your BaxCloud API key
Example
1import { BaxCloudClient } from '@baxcloud/react-native-sdk';
2
3const client = new BaxCloudClient({
4 projectId: 'your-project-id',
5 apiKey: 'your-api-key',
6});Room Management
createRoom
Create a new room
createRoom(options: BaxcloudCreateRoomOptions): Promise<BaxcloudRoomInfo>Parameters
options.roomName(string) - Unique room nameoptions.liveType(BaxcloudLiveType) - Type of live sessionoptions.maxParticipants(number, optional) - Maximum participantsoptions.emptyTimeout(number, optional) - Timeout in seconds when room is emptyoptions.metadata(Record<string, unknown>, optional) - Room metadata
Example
1const room = await client.createRoom({
2 roomName: 'meeting-123',
3 liveType: 'video_conference',
4 maxParticipants: 50,
5});
6
7console.log('Room created:', room.roomName);deleteRoom
Delete a room
deleteRoom(roomName: string): Promise<void>Example
await client.deleteRoom('meeting-123');listRooms
List all rooms in the project
listRooms(): Promise<BaxcloudRoomInfo[]>Example
const rooms = await client.listRooms();
console.log('Total rooms:', rooms.length);getRoom
Get information about a specific room
getRoom(roomName: string): Promise<BaxcloudRoomInfo>Example
const room = await client.getRoom('meeting-123');
console.log('Room info:', room);getToken
Get an access token for joining a room
getToken(options: BaxcloudRoomOptions): Promise<BaxcloudTokenResponse>Parameters
options.roomName(string) - Room nameoptions.participant(BaxcloudUser) - Participant informationoptions.liveType(BaxcloudLiveType) - Type of live sessionoptions.roomMetadata(Record<string, unknown>, optional) - Room metadataoptions.canJoinWithNoHost(boolean, optional) - Allow joining without host (default: true)
Example
1const token = await client.getToken({
2 roomName: 'meeting-123',
3 participant: {
4 userId: 'user-1',
5 name: 'Alice',
6 avatarUrl: 'https://example.com/avatar.jpg',
7 isHost: true,
8 },
9 liveType: 'video_conference',
10});
11
12console.log('Access token:', token.token);Connection Methods
connect
Connect to a room
connect(options: BaxcloudRoomOptions): Promise<Room>Example
1const room = await client.connect({
2 roomName: 'meeting-123',
3 participant: {
4 userId: 'user-1',
5 name: 'Alice',
6 isHost: true,
7 },
8 liveType: 'video_conference',
9});
10
11console.log('Connected to room');disconnect
Disconnect from the current room
disconnect(): Promise<void>Example
await client.disconnect();
console.log('Disconnected from room');getConnectionState
Get the current connection state
getConnectionState(): BaxcloudConnectionStateReturns
One of: 'disconnected' | 'connecting' | 'connected' | 'reconnecting' | 'failed'
Example
const state = client.getConnectionState();
console.log('Connection state:', state);Media Controls
enableCamera
enableCamera(): Promise<void>disableCamera
disableCamera(): Promise<void>enableMicrophone
enableMicrophone(): Promise<void>disableMicrophone
disableMicrophone(): Promise<void>enableScreenShare
enableScreenShare(): Promise<void>Platform-specific implementation
disableScreenShare
disableScreenShare(): Promise<void>Messaging
sendRealtimeMessage
Send a real-time message to the room
sendRealtimeMessage(options: BaxcloudSendRealtimeMessageOptions): Promise<void>Parameters
options.roomName(string) - Room nameoptions.message(string) - Message contentoptions.sender(BaxcloudUser, optional) - Sender user information
Example
1await client.sendRealtimeMessage({
2 roomName: 'meeting-123',
3 message: 'Hello everyone!',
4 sender: {
5 userId: 'user-1',
6 name: 'Alice',
7 },
8});Recording APIs
startRecording
Start recording a room
startRecording(options: BaxcloudStartRecordingOptions): Promise<BaxcloudRecordingInfo>Parameters
options.roomName(string) - Room name to recordoptions.filepath(string, optional) - Custom file path for the recordingoptions.fileType('MP4' | 'OGG' | 'WEBM', optional) - Recording file type (default: 'MP4')
Example
1const recording = await client.startRecording({
2 roomName: 'my-room',
3 fileType: 'MP4',
4});
5
6console.log('Recording started:', recording.egressId);Note: Recording events (recording.started, recording.completed, recording.failed) are automatically sent to your configured webhooks in the dashboard if webhooks are enabled for your project.
stopRecording
Stop an active recording
stopRecording(egressId: string): Promise<{ success: true }>Example
await client.stopRecording(recording.egressId);
console.log('Recording stopped');listActiveRecordings
List all active recordings/egresses
listActiveRecordings(roomName?: string): Promise<BaxcloudRecordingInfo[]>Example
1// List all active recordings
2const activeRecordings = await client.listActiveRecordings();
3
4// List active recordings for a specific room
5const roomRecordings = await client.listActiveRecordings('my-room');listRecordings
List all recordings with pagination support
listRecordings(options?: BaxcloudListRecordingsOptions): Promise<BaxcloudRecordingListResponse>Parameters
options.status(string, optional) - Filter by status ('STARTED' | 'COMPLETED' | 'FAILED')options.page(number, optional) - Page number (default: 1)options.limit(number, optional) - Items per page (default: 10)
Example
1const recordings = await client.listRecordings({
2 status: 'COMPLETED',
3 page: 1,
4 limit: 20,
5});
6
7console.log('Recordings:', recordings.items);
8console.log('Total:', recordings.meta.total);getRecording
Get detailed information about a specific recording
getRecording(recordingId: string): Promise<BaxcloudRecordingInfo>Example
const recording = await client.getRecording('recording-123');
console.log('Recording status:', recording.status);
console.log('File URL:', recording.fileUrl);getRecordingDownloadUrl
Get a temporary download URL for a recording file
getRecordingDownloadUrl(recordingId: string, expiresIn?: number): Promise<{ downloadUrl: string; expiresIn: number }>Parameters
recordingId(string) - Recording IDexpiresIn(number, optional) - URL expiration time in seconds (default: 3600)
Example
1const { downloadUrl, expiresIn } = await client.getRecordingDownloadUrl('recording-123', 7200);
2console.log('Download URL (expires in 2 hours):', downloadUrl);Event Handlers
All event handlers return an unsubscribe function for cleanup.
onUserJoined
onUserJoined(
handler: BaxcloudUserJoinedHandler
): () => voidonUserLeft
onUserLeft(
handler: BaxcloudUserLeftHandler
): () => voidonMessageReceived
onMessageReceived(
handler: BaxcloudMessageReceivedHandler
): () => voidonMediaStarted
onMediaStarted(
handler: BaxcloudMediaStartedHandler
): () => voidonMediaStopped
onMediaStopped(
handler: BaxcloudMediaStoppedHandler
): () => voidonConnected
onConnected(
handler: () => void
): () => voidonDisconnected
onDisconnected(
handler: () => void
): () => voidonReconnecting
onReconnecting(
handler: () => void
): () => voidonReconnected
onReconnected(
handler: () => void
): () => voidEvent Handler Example (React Native)
1import { useEffect } from 'react';
2import { View, Text, Alert } from 'react-native';
3import { useBaxCloud } from '@baxcloud/react-native-sdk';
4
5function MyComponent() {
6 const client = useBaxCloud();
7
8 useEffect(() => {
9 // Subscribe to events
10 const unsubscribeJoined = client.onUserJoined((user) => {
11 Alert.alert('User Joined', `${user.name} joined the room`);
12 });
13
14 const unsubscribeLeft = client.onUserLeft((user) => {
15 Alert.alert('User Left', `${user.name} left the room`);
16 });
17
18 // Clean up on unmount
19 return () => {
20 unsubscribeJoined();
21 unsubscribeLeft();
22 };
23 }, [client]);
24
25 return (
26 <View>
27 <Text>My Component</Text>
28 </View>
29 );
30}BaxCloudProvider
Props
React context provider for BaxCloud client
interface BaxCloudProviderProps {
projectId: string;
apiKey: string;
children: ReactNode;
}Usage
1import { BaxCloudProvider } from '@baxcloud/react-native-sdk';
2import { View } from 'react-native';
3
4function App() {
5 return (
6 <BaxCloudProvider
7 projectId="your-project-id"
8 apiKey="your-api-key"
9 >
10 <YourApp />
11 </BaxCloudProvider>
12 );
13}Hooks
useBaxCloud
Get the BaxCloud client instance from context
useBaxCloud(): BaxCloudClientExample
1import { useBaxCloud } from '@baxcloud/react-native-sdk';
2import { View, TouchableOpacity, Text } from 'react-native';
3
4function MyComponent() {
5 const client = useBaxCloud();
6
7 const createRoom = async () => {
8 await client.createRoom({
9 roomName: 'my-room',
10 liveType: 'video_call',
11 });
12 };
13
14 return (
15 <View>
16 <TouchableOpacity onPress={createRoom}>
17 <Text>Create Room</Text>
18 </TouchableOpacity>
19 </View>
20 );
21}useBaxCloudRoom
Hook for managing room connection state
useBaxCloudRoom(options: BaxcloudRoomOptions | null): {
room: Room | null;
connectionState: BaxcloudConnectionState;
error: Error | null;
connect: () => Promise<void>;
disconnect: () => Promise<void>;
enableCamera: () => Promise<void>;
disableCamera: () => Promise<void>;
enableMicrophone: () => Promise<void>;
disableMicrophone: () => Promise<void>;
enableScreenShare: () => Promise<void>;
disableScreenShare: () => Promise<void>;
}Example
1import { useBaxCloudRoom } from '@baxcloud/react-native-sdk';
2import { useEffect } from 'react';
3import { View, Text, TouchableOpacity } from 'react-native';
4
5function VideoRoom() {
6 const {
7 room,
8 connectionState,
9 connect,
10 disconnect,
11 enableCamera,
12 disableCamera,
13 } = useBaxCloudRoom({
14 roomName: 'my-room',
15 participant: {
16 userId: 'user-1',
17 name: 'John Doe',
18 isHost: true,
19 },
20 liveType: 'video_call',
21 });
22
23 useEffect(() => {
24 connect();
25 return () => disconnect();
26 }, []);
27
28 if (connectionState !== 'connected') {
29 return (
30 <View>
31 <Text>Connecting...</Text>
32 </View>
33 );
34 }
35
36 return (
37 <View>
38 <Text>Video Call</Text>
39 <TouchableOpacity onPress={enableCamera}>
40 <Text>Enable Camera</Text>
41 </TouchableOpacity>
42 <TouchableOpacity onPress={disableCamera}>
43 <Text>Disable Camera</Text>
44 </TouchableOpacity>
45 <TouchableOpacity onPress={disconnect}>
46 <Text>Leave</Text>
47 </TouchableOpacity>
48 </View>
49 );
50}useBaxCloudParticipants
Hook that returns all participants in the room
useBaxCloudParticipants(room: Room | null): Participant[]Example
1import { useBaxCloudRoom, useBaxCloudParticipants } from '@baxcloud/react-native-sdk';
2import { View, Text, FlatList } from 'react-native';
3
4function ParticipantsList() {
5 const { room } = useBaxCloudRoom({
6 roomName: 'my-room',
7 participant: { userId: 'user-1', name: 'John' },
8 liveType: 'video_conference',
9 });
10
11 const participants = useBaxCloudParticipants(room);
12
13 return (
14 <View>
15 <Text>Participants ({participants.length})</Text>
16 <FlatList
17 data={participants}
18 keyExtractor={(item) => item.identity}
19 renderItem={({ item }) => (
20 <View>
21 <Text>{item.name || item.identity}</Text>
22 </View>
23 )}
24 />
25 </View>
26 );
27}useBaxCloudTracks
Hook that returns all tracks (audio/video) in the room
useBaxCloudTracks(room: Room | null): (RemoteTrack | LocalTrack)[]Example
1import { useBaxCloudRoom, useBaxCloudTracks } from '@baxcloud/react-native-sdk';
2import { View, Text } from 'react-native';
3
4function TracksList() {
5 const { room } = useBaxCloudRoom({
6 roomName: 'my-room',
7 participant: { userId: 'user-1', name: 'John' },
8 liveType: 'video_call',
9 });
10
11 const tracks = useBaxCloudTracks(room);
12
13 return (
14 <View>
15 <Text>Active Tracks: {tracks.length}</Text>
16 </View>
17 );
18}BaxCloudRoomController
Overview
Singleton controller for centralized room management
Access the controller via BaxCloudRoomController.instance
Initialization
1import { BaxCloudRoomController, useBaxCloud } from '@baxcloud/react-native-sdk';
2import { useEffect } from 'react';
3
4function App() {
5 const client = useBaxCloud();
6 const controller = BaxCloudRoomController.instance;
7
8 useEffect(() => {
9 controller.init(client);
10 }, [client]);
11
12 return <View>App</View>;
13}Host/Co-Host Management
isHost
isHost(): booleanisCoHost
isCoHost(userId?: string): booleantransferHost
transferHost(
targetUserId: string
): Promise<void>Host only
promoteToCoHost
promoteToCoHost(
userId: string
): Promise<void>Host only
demoteFromCoHost
demoteFromCoHost(
userId: string
): Promise<void>Host only
getCoHosts
getCoHosts(): string[]Participant Management
getParticipants
getParticipants(): Participant[]getParticipant
getParticipant(
userId: string
): Participant | nullkickParticipant
kickParticipant(
userId: string,
reason?: string
): Promise<void>Host/Co-host only
pinParticipant
pinParticipant(
userId: string
): Promise<void>unpinParticipant
unpinParticipant(
userId: string
): Promise<void>getPinnedParticipants
getPinnedParticipants(): string[]spotlightParticipant
spotlightParticipant(
userId: string
): Promise<void>Host/Co-host only
unspotlightParticipant
unspotlightParticipant(
userId: string
): Promise<void>Host/Co-host only
getSpotlightedParticipants
getSpotlightedParticipants(): string[]Audio/Video Controls
muteMicrophone
muteMicrophone(): Promise<void>unmuteMicrophone
unmuteMicrophone(): Promise<void>isMicrophoneMuted
isMicrophoneMuted(): booleanenableCamera
enableCamera(): Promise<void>disableCamera
disableCamera(): Promise<void>isCameraEnabled
isCameraEnabled(): booleanswitchCamera
switchCamera(): Promise<void>Switch between front and back camera (mobile only)
muteAll
muteAll(): Promise<void>Host only
unmuteAll
unmuteAll(): Promise<void>Host only
muteParticipant
muteParticipant(
userId: string
): Promise<void>Host/Co-host only
unmuteParticipant
unmuteParticipant(
userId: string
): Promise<void>Host/Co-host only
Screen Sharing
enableScreenShare
enableScreenShare(): Promise<void>Platform-specific implementation required
disableScreenShare
disableScreenShare(): Promise<void>isScreenShareEnabled
isScreenShareEnabled(): booleanChat System
sendChatMessage
sendChatMessage(
message: string
): Promise<void>getChatHistory
getChatHistory(): BaxcloudChatMessage[]clearChatHistory
clearChatHistory(): voidstartTyping
startTyping(): Promise<void>Auto-stops after 3 seconds
stopTyping
stopTyping(): Promise<void>getTypingIndicators
getTypingIndicators(): BaxcloudTypingIndicator[]Invitation System
sendCallInvitation
sendCallInvitation(
options: BaxcloudInvitationOptions
): Promise<{ success: boolean; invitationId: string }>Parameters
options.to(string[]) - Array of user IDs to inviteoptions.roomName(string) - Room nameoptions.callType(BaxcloudLiveType) - Type of calloptions.message(string, optional) - Optional messageoptions.roomUrl(string, optional) - Optional room URL
acceptCallInvitation
acceptCallInvitation(
invitationId: string
): Promise<void>declineCallInvitation
declineCallInvitation(
invitationId: string
): Promise<void>cancelCallInvitation
cancelCallInvitation(
invitationId: string
): Promise<void>Raise Hand
raiseHand
raiseHand(): Promise<void>lowerHand
lowerHand(userId?: string): Promise<void>getRaisedHands
getRaisedHands(): BaxcloudRaisedHand[]Network Quality
getNetworkQuality
getNetworkQuality(): BaxcloudNetworkQualityReturns
{
connectionQuality: 'excellent' | 'good' | 'poor' | 'unknown';
rtt?: number;
jitter?: number;
packetLoss?: number;
}getParticipantQuality
getParticipantQuality(
userId: string
): BaxcloudNetworkQualityCall Management
getCallHistory
getCallHistory(): BaxcloudCallRecord[]getCall
getCall(
callId: string
): BaxcloudCallRecord | undefinedendCall
endCall(): Promise<void>Polling/Q&A
createPoll
createPoll(
question: string,
options: string[]
): Promise<string>Host/Co-host only. Returns poll ID
respondToPoll
respondToPoll(
pollId: string,
selectedOption: string
): Promise<void>endPoll
endPoll(pollId: string): Promise<void>Host/Co-host only
getActivePolls
getActivePolls(): BaxcloudPoll[]getPoll
getPoll(
pollId: string
): BaxcloudPoll | undefinedBreakout Rooms
createBreakoutRoom
createBreakoutRoom(
roomName: string,
participantIds: string[]
): Promise<string>Host/Co-host only. Returns room ID
joinBreakoutRoom
joinBreakoutRoom(
roomId: string
): Promise<void>leaveBreakoutRoom
leaveBreakoutRoom(
roomId: string
): Promise<void>getBreakoutRooms
getBreakoutRooms(): BaxcloudBreakoutRoom[]getBreakoutRoom
getBreakoutRoom(
roomId: string
): BaxcloudBreakoutRoom | undefinedEmoji Reactions
sendEmojiReaction
sendEmojiReaction(
emoji: string
): Promise<void>getRecentEmojiReactions
getRecentEmojiReactions(): BaxcloudEmojiReaction[]Waiting Room
approveWaitingRoomParticipant
approveWaitingRoomParticipant(
userId: string
): Promise<void>Host/Co-host only
rejectWaitingRoomParticipant
rejectWaitingRoomParticipant(
userId: string
): Promise<void>Host/Co-host only
getWaitingRoomParticipants
getWaitingRoomParticipants(): BaxcloudWaitingRoomParticipant[]Host/Co-host only
Picture-in-Picture
enablePIP
enablePIP(): Promise<void>iOS: Requires iOS 15+, Android: API 26+
disablePIP
disablePIP(): Promise<void>isPIPEnabled
isPIPEnabled(): booleanBackground Effects
applyBackgroundEffect
applyBackgroundEffect(
effect: BaxcloudBackgroundEffect
): Promise<void>Effect Parameters
effect.effectId(string) - Effect identifiereffect.effectType('blur' | 'virtual' | 'image' | 'video') - Effect typeeffect.intensity(number, optional) - Effect intensityeffect.imageUrl(string, optional) - Image URL for image effecteffect.videoUrl(string, optional) - Video URL for video effect
Note: Background effects may require additional native setup and permissions
removeBackgroundEffect
removeBackgroundEffect(): Promise<void>getCurrentBackgroundEffect
getCurrentBackgroundEffect(): BaxcloudBackgroundEffect | nullAccessibility
updateAccessibilitySettings
updateAccessibilitySettings(
settings: Partial<BaxcloudAccessibilitySettings>
): voidSettings Parameters
settings.enableSubtitles(boolean, optional)settings.enableClosedCaptions(boolean, optional)settings.fontSize('small' | 'medium' | 'large' | 'xlarge', optional)settings.highContrast(boolean, optional)settings.reduceMotion(boolean, optional)
getAccessibilitySettings
getAccessibilitySettings(): BaxcloudAccessibilitySettingsType Definitions
BaxcloudLiveType
type BaxcloudLiveType =
| 'audio_call'
| 'video_call'
| 'audio_conference'
| 'video_conference'
| 'live_streaming'
| 'webinar'
| 'screen_share'
| 'recording';BaxcloudConnectionState
type BaxcloudConnectionState =
| 'disconnected'
| 'connecting'
| 'connected'
| 'reconnecting'
| 'failed';BaxcloudUser
interface BaxcloudUser {
userId: string;
name: string;
avatarUrl?: string;
isHost?: boolean;
metadata?: Record<string, unknown>;
}BaxcloudRoomOptions
interface BaxcloudRoomOptions {
roomName: string;
participant: BaxcloudUser;
liveType: BaxcloudLiveType;
roomMetadata?: Record<string, unknown>;
canJoinWithNoHost?: boolean; // Default: true
}BaxcloudNetworkQuality
interface BaxcloudNetworkQuality {
connectionQuality: 'excellent' | 'good' | 'poor' | 'unknown';
rtt?: number;
jitter?: number;
packetLoss?: number;
}BaxcloudChatMessage
interface BaxcloudChatMessage {
messageId: string;
userId: string;
userName: string;
message: string;
timestamp: Date;
type: 'text' | 'system' | 'realtime';
avatarUrl?: string;
}