### Start Example App Packager
Source: https://github.com/livekit/client-sdk-react-native/blob/main/CONTRIBUTING.md
Starts the Metro server for the example application, allowing for live updates during development.
```sh
yarn example start
```
--------------------------------
### Basic LiveKitRoom Setup
Source: https://github.com/livekit/client-sdk-react-native/blob/main/docs/functions/LiveKitRoom.html
This example shows the basic setup for the LiveKitRoom component. Ensure you provide a valid token and server URL. The 'connect' prop should be set to true to establish a connection.
```html
...
```
--------------------------------
### Bootstrap Project Dependencies and Pods
Source: https://github.com/livekit/client-sdk-react-native/blob/main/CONTRIBUTING.md
Installs all project dependencies and initializes CocoaPods for the iOS example app.
```sh
yarn bootstrap
```
--------------------------------
### Run Example App on iOS
Source: https://github.com/livekit/client-sdk-react-native/blob/main/CONTRIBUTING.md
Builds and runs the example application on an iOS device or simulator.
```sh
yarn example ios
```
--------------------------------
### Run Example App on Android
Source: https://github.com/livekit/client-sdk-react-native/blob/main/CONTRIBUTING.md
Builds and runs the example application on an Android device or emulator.
```sh
yarn example android
```
--------------------------------
### Install Project Dependencies
Source: https://github.com/livekit/client-sdk-react-native/blob/main/CONTRIBUTING.md
Run this command in the root directory to install all necessary dependencies for the project packages.
```sh
yarn
```
--------------------------------
### setup Method
Source: https://github.com/livekit/client-sdk-react-native/blob/main/docs/classes/RNE2EEManager.html
Sets up the E2EEManager. This method is documented but has no signature or parameters provided in the source.
```APIDOC
## setup Method
### Description
Sets up the E2EEManager. This is an experimental feature.
*Note: The source documentation for this method does not include its signature or parameters.*
```
--------------------------------
### Install with NPM
Source: https://github.com/livekit/client-sdk-react-native/blob/main/README.md
Install the necessary LiveKit packages using NPM. This includes the core React Native SDK, the WebRTC module, and the base client.
```sh
npm install @livekit/react-native @livekit/react-native-webrtc livekit-client
```
--------------------------------
### setup
Source: https://github.com/livekit/client-sdk-react-native/blob/main/docs/classes/RNE2EEManager.html
Sets up the end-to-end encryption manager with a given Room. This method is experimental.
```APIDOC
## setup
### Description
Sets up the end-to-end encryption manager with a given Room. This method is experimental.
### Method
Not applicable (TypeScript method)
### Parameters
#### Path Parameters
None
#### Query Parameters
None
#### Request Body
None
### Parameters
* **room** (Room) - Description: The Room object to set up the E2EE manager with.
### Returns void
### Example
```typescript
// Assuming 'rneE2eManager' is an instance of RNE2EEManager and 'myRoom' is a Room object
rneE2eManager.setup(myRoom);
```
```
--------------------------------
### iOS Setup (Swift)
Source: https://github.com/livekit/client-sdk-react-native/blob/main/README.md
Configure the LiveKit SDK in your iOS application's AppDelegate.swift file. This setup should precede other React Native initializations. Optional settings for background camera access can be enabled.
```swift
import livekit_react_native
import livekit_react_native_webrtc
@main
class AppDelegate: UIResponder, UIApplicationDelegate {
func application(
_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? = nil
) -> Bool {
// Place this above any other RN related initialization
LivekitReactNative.setup()
// Uncomment the following lines if you want to use the camera in the background
// Requires voip background mode and iOS 18+.
// let options = WebRTCModuleOptions.sharedInstance()
// options.enableMultitaskingCameraAccess = true
// ...
}
}
```
--------------------------------
### iOS Setup (Objective-C)
Source: https://github.com/livekit/client-sdk-react-native/blob/main/README.md
Configure the LiveKit SDK in your iOS application's AppDelegate.m file. This setup should precede other React Native initializations. Optional settings for background camera access can be enabled.
```objc
#import "LivekitReactNative.h"
#import "WebRTCModuleOptions.h"
@implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// Place this above any other RN related initialization
[LivekitReactNative setup];
// Uncomment the following lines if you want to use the camera in the background
// Requires voip background mode and iOS 18+.
// WebRTCModuleOptions *options = [WebRTCModuleOptions sharedInstance];
// options.enableMultitaskingCameraAccess = YES;
//...
}
```
--------------------------------
### Install with Yarn
Source: https://github.com/livekit/client-sdk-react-native/blob/main/README.md
Install the necessary LiveKit packages using Yarn. This includes the core React Native SDK, the WebRTC module, and the base client.
```sh
yarn add @livekit/react-native @livekit/react-native-webrtc livekit-client
```
--------------------------------
### SimpleVoiceAssistant Example
Source: https://github.com/livekit/client-sdk-react-native/blob/main/docs/functions/BarVisualizer.html
Demonstrates how to use the BarVisualizer component to visualize audio tracks and manage voice assistant states.
```typescript
function SimpleVoiceAssistant() {
const { state, audioTrack } = useVoiceAssistant();
return (
);
}
```
--------------------------------
### Android Setup (Kotlin)
Source: https://github.com/livekit/client-sdk-react-native/blob/main/README.md
Configure the LiveKit SDK in your Android application's MainApplication.kt file. This setup should precede other React Native initializations. You can specify audio types like CommunicationAudioType or MediaAudioType.
```kotlin
import com.livekit.reactnative.LiveKitReactNative
import com.livekit.reactnative.audio.AudioType
class MainApplication : Application, ReactApplication() {
override fun onCreate() {
// Place this above any other RN related initialization
// When AudioType is omitted, it'll default to CommunicationAudioType.
// Use MediaAudioType if user is only consuming audio, and not publishing.
LiveKitReactNative.setup(this, AudioType.CommunicationAudioType())
//...
}
}
```
--------------------------------
### Run Android App
Source: https://github.com/livekit/client-sdk-react-native/blob/main/example/README.md
Execute this command to build and run the Android version of the example application.
```sh
yarn android
```
--------------------------------
### iOS Setup (Objective-C)
Source: https://github.com/livekit/client-sdk-react-native/blob/main/docs/index.html
Configure LivekitReactNative in your AppDelegate.m file for iOS. This setup should precede other RN related initializations. Background camera usage can be enabled by uncommenting specific lines, which requires voip background mode and iOS 18+.
```objectivec
#import "LivekitReactNative.h"
#import "WebRTCModuleOptions.h"
@implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions{
// Place this above any other RN related initialization
[LivekitReactNative setup];
// Uncomment the following lines if you want to use the camera in the background
// Requires voip background mode and iOS 18+.
// WebRTCModuleOptions *options = [WebRTCModuleOptions sharedInstance];
// options.enableMultitaskingCameraAccess = YES;
//...
}
@end
```
--------------------------------
### iOS Setup (Swift)
Source: https://github.com/livekit/client-sdk-react-native/blob/main/docs/index.html
Configure LivekitReactNative in your AppDelegate.swift file for iOS. This setup should precede other RN related initializations. Background camera usage can be enabled by uncommenting specific lines, which requires voip background mode and iOS 18+.
```swift
import livekit_react_native
import livekit_react_native_webrtc
@main
class AppDelegate: UIResponder, UIApplicationDelegate {
func application(
_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? = nil
) -> Bool {
// Place this above any other RN related initialization
LivekitReactNative.setup()
// Uncomment the following lines if you want to use the camera in the background
// Requires voip background mode and iOS 18+.
// let options = WebRTCModuleOptions.sharedInstance()
// options.enableMultitaskingCameraAccess = true
// ...
}
}
```
--------------------------------
### Android Setup (Java)
Source: https://github.com/livekit/client-sdk-react-native/blob/main/README.md
Configure the LiveKit SDK in your Android application's MainApplication.java file. This setup should precede other React Native initializations. You can specify audio types like CommunicationAudioType or MediaAudioType.
```java
import com.livekit.reactnative.LiveKitReactNative;
import com.livekit.reactnative.audio.AudioType;
public class MainApplication extends Application implements ReactApplication {
@Override
public void onCreate() {
// Place this above any other RN related initialization
// When AudioType is omitted, it'll default to CommunicationAudioType.
// Use MediaAudioType if user is only consuming audio, and not publishing.
LiveKitReactNative.setup(this, new AudioType.CommunicationAudioType());
//...
}
}
```
--------------------------------
### Install iOS Pods
Source: https://github.com/livekit/client-sdk-react-native/blob/main/example/README.md
Navigate to the ios directory and run this command to generate the Pod project for iOS.
```sh
cd ios
pod install
```
--------------------------------
### Custom iOS Audio Management Setup
Source: https://github.com/livekit/client-sdk-react-native/blob/main/docs/index.html
Disable default setup and manually call setupIOSAudioManagement for custom automatic audio behavior during app startup.
```javascript
import { registerGlobals, setupIOSAudioManagement } from '@livekit/react-native';
registerGlobals({ autoConfigureAudioSession: false });
const cleanup = setupIOSAudioManagement(true, (state) => ({
audioCategory: state.isRecordingEnabled ? 'playAndRecord' : 'playback',
audioCategoryOptions: ['mixWithOthers'],
audioMode: state.preferSpeakerOutput ? 'videoChat' : 'voiceChat',
}));
```
--------------------------------
### startAudioSession
Source: https://github.com/livekit/client-sdk-react-native/blob/main/docs/classes/AudioSession.html
Starts an AudioSession. This method should be called to initialize the audio handling capabilities.
```APIDOC
## startAudioSession
### Description
Starts an AudioSession. This method should be called to initialize the audio handling capabilities.
### Method
Static method
### Endpoint
N/A
### Parameters
#### Path Parameters
None
#### Query Parameters
None
#### Request Body
None
### Returns
Promise
### Request Example
```javascript
AudioSession.startAudioSession();
```
### Response
#### Success Response (void)
This method does not return a value upon success.
#### Response Example
None
```
--------------------------------
### Setup iOS Audio Management
Source: https://github.com/livekit/client-sdk-react-native/blob/main/docs/functions/setupIOSAudioManagement.html
Call this once at app startup to set up automatic iOS audio session management. It can optionally take a custom callback for determining audio configuration. A cleanup function is returned to remove event handlers.
```typescript
setupIOSAudioManagement(
preferSpeakerOutput?: boolean,
onConfigureNativeAudio?: (
configurationState: AudioEngineConfigurationState
) => AppleAudioConfiguration,
): () => void
```
--------------------------------
### Android Setup (Java)
Source: https://github.com/livekit/client-sdk-react-native/blob/main/docs/index.html
Configure LiveKitReactNative in your MainApplication.java file for Android. Ensure this is placed above other RN related initializations. The AudioType can be omitted to default to CommunicationAudioType, or set to MediaAudioType if only consuming audio.
```java
import com.livekit.reactnative.LiveKitReactNative;
import com.livekit.reactnative.audio.AudioType;
public class MainApplication extends Application implements ReactApplication {
@Override
public void onCreate() {
// Place this above any other RN related initialization
// When AudioType is omitted, it'll default to CommunicationAudioType.
// Use MediaAudioType if user is only consuming audio, and not publishing.
LiveKitReactNative.setup(this, new AudioType.CommunicationAudioType());
//...
}
}
```
--------------------------------
### Custom iOS Audio Management Setup
Source: https://github.com/livekit/client-sdk-react-native/blob/main/README.md
For custom automatic audio behavior on iOS, disable the default setup and call setupIOSAudioManagement during app startup. This hook allows fine-grained control over audio category, options, and mode based on application state.
```javascript
import { registerGlobals, setupIOSAudioManagement } from '@livekit/react-native';
registerGlobals({ autoConfigureAudioSession: false });
const cleanup = setupIOSAudioManagement(true, (state) => ({
audioCategory: state.isRecordingEnabled ? 'playAndRecord' : 'playback',
audioCategoryOptions: ['mixWithOthers'],
audioMode: state.preferSpeakerOutput ? 'videoChat' : 'voiceChat',
}));
```
--------------------------------
### Basic LiveKit Room Integration
Source: https://github.com/livekit/client-sdk-react-native/blob/main/README.md
Wrap your main app component with LiveKitRoom to manage the Room object and enable hooks for real-time video and audio. Ensure the audio session is started before connecting.
```javascript
import * as React from 'react';
import {
StyleSheet,
View,
FlatList,
ListRenderItem,
} from 'react-native';
import { useEffect } from 'react';
import {
AudioSession,
LiveKitRoom,
useTracks,
TrackReferenceOrPlaceholder,
VideoTrack,
isTrackReference,
registerGlobals,
} from '@livekit/react-native';
import { Track } from 'livekit-client';
const wsURL = "wss://example.com"
const token = "your-token-here"
export default function App() {
// Start the audio session first.
useEffect(() => {
let start = async () => {
await AudioSession.startAudioSession();
};
start();
return () => {
AudioSession.stopAudioSession();
};
}, []);
return (
);
};
const RoomView = () => {
// Get all camera tracks.
// The useTracks hook grabs the tracks from LiveKitRoom component
// providing the context for the Room object.
const tracks = useTracks([Track.Source.Camera]);
const renderTrack: ListRenderItem = ({item}) => {
// Render using the VideoTrack component.
if(isTrackReference(item)) {
return ()
} else {
return ()
}
};
return (
);
};
const styles = StyleSheet.create({
container: {
flex: 1,
alignItems: 'stretch',
justifyContent: 'center',
},
participantView: {
height: 300,
},
});
```
--------------------------------
### Configure Audio Session for Media Playback (Android)
Source: https://github.com/livekit/client-sdk-react-native/blob/main/docs/index.html
Reconfigures the audio session for media playback on Android before starting it. This is useful when LiveKit is primarily used for playing media rather than bidirectional communication.
```javascript
useEffect(() => {
let connect = async () => {
// configure audio session prior to starting it.
await AudioSession.configureAudio({
android: {
// currently supports .media and .communication presets
audioTypeOptions: AndroidAudioTypePresets.media,
},
});
await AudioSession.startAudioSession();
await room.connect(url, token, {});
};
connect();
return () => {
room.disconnect();
AudioSession.stopAudioSession();
};
}, [url, token, room]);
```
--------------------------------
### Configuring and Controlling iOS Picture-in-Picture (PiP)
Source: https://github.com/livekit/client-sdk-react-native/blob/main/docs/types/VideoTrackProps.html
Example demonstrating how to configure and manually control Picture-in-Picture mode for a VideoTrack component on iOS. Requires importing specific functions and obtaining a ref to the video view.
```typescript
import { startIOSPIP, stopIOSPIP } from '@livekit/react-native-webrtc';
// Obtain a ref to the view
const videoRef = useRef(null);
const videoView = (
);// Start/stop manually
startIOSPIP(videoRef);
stopIOSPIP(videoRef);
```
--------------------------------
### Configure Android Audio for Media Playback
Source: https://github.com/livekit/client-sdk-react-native/blob/main/README.md
Reconfigure the audio session for media playback on Android by setting the audioTypeOptions to .media before starting the session and connecting to the room.
```javascript
useEffect(() => {
let connect = async () => {
// configure audio session prior to starting it.
await AudioSession.configureAudio({
android: {
// currently supports .media and .communication presets
audioTypeOptions: AndroidAudioTypePresets.media,
},
});
await AudioSession.startAudioSession();
await room.connect(url, token, {});
};
connect();
return () => {
room.disconnect();
AudioSession.stopAudioSession();
};
}, [url, token, room]);
```
--------------------------------
### LiveKitRoom
Source: https://github.com/livekit/client-sdk-react-native/blob/main/docs/functions/LiveKitRoom.html
The LiveKitRoom component provides the room context to all its child components. It is generally the starting point of your LiveKit app and the root of the LiveKit component tree. It provides the room state as a React context to all child components, so you don't have to pass it yourself.
```APIDOC
## LiveKitRoom
### Description
The `LiveKitRoom` component provides the room context to all its child components. It is generally the starting point of your LiveKit app and the root of the LiveKit component tree. It provides the room state as a React context to all child components, so you don't have to pass it yourself.
### Parameters
* **props**: PropsWithChildren<[LiveKitRoomProps](../interfaces/LiveKitRoomProps.html)
angle
### Returns Element
### Example
```jsx
...
```
```
--------------------------------
### Customize Android Audio Session Configuration
Source: https://github.com/livekit/client-sdk-react-native/blob/main/README.md
Further customize the Android audio session by specifying preferred output devices and detailed audio type options, including focus management and stream types, before starting the audio session.
```javascript
await AudioSession.configureAudio({
android: {
preferredOutputList: ['earpiece'],
// See [AudioManager](https://developer.android.com/reference/android/media/AudioManager)
// for details on audio and focus modes.
audioTypeOptions: {
manageAudioFocus: true,
audioMode: 'normal',
audioFocusMode: 'gain',
audioStreamType: 'music',
audioAttributesUsageType: 'media',
audioAttributesContentType: 'unknown',
},
},
});
await AudioSession.startAudioSession();
```
--------------------------------
### setupEngine Method
Source: https://github.com/livekit/client-sdk-react-native/blob/main/docs/classes/RNE2EEManager.html
Sets up the engine for E2EEManager. This method is documented but has no signature or parameters provided in the source.
```APIDOC
## setupEngine Method
### Description
Sets up the engine for E2EEManager. This is an experimental feature.
*Note: The source documentation for this method does not include its signature or parameters.*
```
--------------------------------
### setupEngine
Source: https://github.com/livekit/client-sdk-react-native/blob/main/docs/classes/RNE2EEManager.html
Sets up the end-to-end encryption manager with an RTCEngine. This method is experimental.
```APIDOC
## setupEngine
### Description
Sets up the end-to-end encryption manager with an RTCEngine. This method is experimental.
### Method
Not applicable (TypeScript method)
### Parameters
#### Path Parameters
None
#### Query Parameters
None
#### Request Body
None
### Parameters
* **_engine** (RTCEngine) - Description: The RTCEngine instance to set up.
### Returns void
### Example
```typescript
// Assuming 'rneE2eManager' is an instance of RNE2EEManager and 'myEngine' is an RTCEngine object
rneE2eManager.setupEngine(myEngine);
```
```
--------------------------------
### isEnabled Accessor
Source: https://github.com/livekit/client-sdk-react-native/blob/main/docs/classes/RNE2EEManager.html
Gets the enabled state of the E2EEManager. This is an experimental feature.
```APIDOC
## isEnabled Accessor
### Description
Gets the enabled state of the E2EEManager. This is an experimental feature.
### Getter
* **isEnabled**(): boolean
```
--------------------------------
### isDataChannelEncryptionEnabled Accessor
Source: https://github.com/livekit/client-sdk-react-native/blob/main/docs/classes/RNE2EEManager.html
Gets or sets the state of data channel encryption. This is an experimental feature.
```APIDOC
## isDataChannelEncryptionEnabled Accessor
### Description
Gets or sets the state of data channel encryption. This is an experimental feature.
### Getter
* **isDataChannelEncryptionEnabled**(): boolean
### Setter
* **isDataChannelEncryptionEnabled**(value: boolean): void
```
--------------------------------
### Disable Automatic Audio Session Configuration for iOS
Source: https://github.com/livekit/client-sdk-react-native/blob/main/README.md
If your app manages AVAudioSession directly, disable the automatic setup provided by registerGlobals.
```javascript
registerGlobals({ autoConfigureAudioSession: false });
```
--------------------------------
### setupIOSAudioManagement
Source: https://github.com/livekit/client-sdk-react-native/blob/main/docs/functions/setupIOSAudioManagement.html
Sets up automatic iOS audio session management based on audio engine state. It's recommended to call this once at app startup. The `registerGlobals()` function calls this by default unless `autoConfigureAudioSession: false` is specified.
```APIDOC
## Function: setupIOSAudioManagement
### Description
Sets up automatic iOS audio session management based on audio engine state.
### Parameters
#### Optional Parameters
* **preferSpeakerOutput** (boolean) - Optional - Whether to prefer speaker output. Defaults to true.
* **onConfigureNativeAudio** (function) - Optional - A custom callback for determining audio configuration. It receives `configurationState` of type `AudioEngineConfigurationState` and returns an `AppleAudioConfiguration`.
### Returns
* **function** - A cleanup function that removes the event handlers.
```
--------------------------------
### Basic LiveKit Room Integration
Source: https://github.com/livekit/client-sdk-react-native/blob/main/docs/index.html
Sets up and connects to a LiveKit room using the LiveKitRoom component. This component manages the room connection and provides context for hooks like useTracks.
```javascript
import * as React from 'react';
import {
StyleSheet,
View,
FlatList,
ListRenderItem,
} from 'react-native';
import { useEffect } from 'react';
import {
AudioSession,
LiveKitRoom,
useTracks,
TrackReferenceOrPlaceholder,
VideoTrack,
isTrackReference,
registerGlobals,
} from '@livekit/react-native';
import { Track } from 'livekit-client';
const wsURL = "wss://example.com"
const token = "your-token-here"
export default function App() {
// Start the audio session first.
useEffect(() => {
let start = async () => {
await AudioSession.startAudioSession();
};
start();
return () => {
AudioSession.stopAudioSession();
};
}, []);
return (
);
};
const RoomView = () => {
// Get all camera tracks.
// The useTracks hook grabs the tracks from LiveKitRoom component
// providing the context for the Room object.
const tracks = useTracks([Track.Source.Camera]);
const renderTrack: ListRenderItem = ({item}) => {
// Render using the VideoTrack component.
if(isTrackReference(item)) {
return ()
} else {
return ()
}
};
return (
);
};
const styles = StyleSheet.create({
container: {
flex: 1,
alignItems: 'stretch',
justifyContent: 'center',
},
participantView: {
height: 300,
},
});
```
--------------------------------
### RNKeyProvider Constructor
Source: https://github.com/livekit/client-sdk-react-native/blob/main/docs/classes/RNKeyProvider.html
Initializes a new instance of the RNKeyProvider class. This is an experimental feature.
```APIDOC
## new RNKeyProvider(options: Partial): RNKeyProvider
### Description
Initializes a new instance of the RNKeyProvider class.
### Parameters
#### Path Parameters
* None
#### Query Parameters
* None
#### Request Body
* **options** (Partial) - Optional - Configuration options for the key provider.
### Request Example
```json
{
"options": {}
}
```
### Response
#### Success Response (200)
* **RNKeyProvider** - An instance of the RNKeyProvider.
#### Response Example
```json
{
"RNKeyProvider": "instance"
}
```
```
--------------------------------
### configureAudio
Source: https://github.com/livekit/client-sdk-react-native/blob/main/docs/classes/AudioSession.html
Applies the provided audio configuration to the underlying AudioSession. This must be called prior to connecting to a Room for the configuration to apply correctly. See also setupIOSAudioManagement for automatic configuration of iOS audio options.
```APIDOC
## configureAudio
### Description
Applies the provided audio configuration to the underlying AudioSession. Must be called prior to connecting to a Room for the configuration to apply correctly.
### Method
Static
### Parameters
#### Path Parameters
None
#### Query Parameters
None
#### Request Body
None
### Request Example
None
### Response
#### Success Response (200)
None
#### Response Example
None
### Parameters
* **config** (AudioConfiguration) - Required - The audio configuration to apply.
```
--------------------------------
### Open iOS Project in Xcode
Source: https://github.com/livekit/client-sdk-react-native/blob/main/example/README.md
Open the generated Pod project in Xcode to further configure and run the iOS application.
```sh
open LivekitReactNativeExample.xcworkspace
```
--------------------------------
### getAudioOutputs
Source: https://github.com/livekit/client-sdk-react-native/blob/main/docs/classes/AudioSession.html
Gets the available audio outputs for use with selectAudioOutput. startAudioSession must be called prior to using this method. For Android, will return if available: "speaker", "earpiece", "headset", "bluetooth". For iOS, due to OS limitations, the only available types are: "default" - Use default iOS audio routing, "force_speaker" - Force audio output through speaker. See also showAudioRoutePicker to display a route picker that can choose between other audio devices (i.e. headset/bluetooth/airplay), or use a library like react-native-avroutepicker for a native platform control.
```APIDOC
## getAudioOutputs
### Description
Gets the available audio outputs for use with [selectAudioOutput](#selectaudiooutput). [startAudioSession](#startaudiosession) must be called prior to using this method.
### Method
Static
### Parameters
#### Path Parameters
None
#### Query Parameters
None
#### Request Body
None
### Request Example
None
### Response
#### Success Response (200)
* **string[]** - The available audio output types
#### Response Example
None
### Returns
Promise
```
--------------------------------
### selectAudioOutput
Source: https://github.com/livekit/client-sdk-react-native/blob/main/docs/classes/AudioSession.html
Select the provided audio output if available. startAudioSession must be called prior to using this method.
```APIDOC
## selectAudioOutput
### Description
Select the provided audio output if available. [startAudioSession](#startaudiosession) must be called prior to using this method.
### Method
Static
### Parameters
#### Path Parameters
None
#### Query Parameters
None
#### Request Body
None
### Request Example
None
### Response
#### Success Response (200)
None
#### Response Example
None
### Parameters
* **deviceId** (string) - Required - A deviceId retrieved from [getAudioOutputs](#getaudiooutputs)
```
--------------------------------
### Classes
Source: https://github.com/livekit/client-sdk-react-native/blob/main/docs/modules.html
Exposes the core classes for managing audio sessions and end-to-end encryption.
```APIDOC
## Classes
### AudioSession
Manages audio-related functionalities within the LiveKit environment.
### RNE2EEManager
Handles end-to-end encryption management for React Native applications.
### RNKeyProvider
Provides key management services for encryption.
```
--------------------------------
### RNE2EEManager Constructor
Source: https://github.com/livekit/client-sdk-react-native/blob/main/docs/classes/RNE2EEManager.html
Initializes a new instance of the RNE2EEManager class. This is an experimental feature.
```APIDOC
## constructor new RNE2EEManager
### Description
Initializes a new instance of the RNE2EEManager class. This is an experimental feature.
### Parameters
* **keyProvider** (RNKeyProvider) - The key provider for encryption.
* **dcEncryptionEnabled** (boolean) - Optional. Whether data channel encryption is enabled. Defaults to false.
### Returns
RNE2EEManager
```
--------------------------------
### useIOSAudioManagement
Source: https://github.com/livekit/client-sdk-react-native/blob/main/docs/functions/useIOSAudioManagement.html
Manages the audio session on iOS devices. This function is deprecated and users should migrate to `setupIOSAudioManagement` for current audio session management.
```APIDOC
## Function useIOSAudioManagement
### Description
Manages the audio session on iOS devices. This function is deprecated and users should migrate to `setupIOSAudioManagement` for current audio session management.
### Signature
`useIOSAudioManagement(_room: Room, preferSpeakerOutput?: boolean, onConfigureNativeAudio?: (trackState: AudioTrackState, preferSpeakerOutput: boolean) => AppleAudioConfiguration): void[]`
### Parameters
* `_room` (Room) - The room object. This parameter is ignored in the current implementation.
* `preferSpeakerOutput` (boolean, optional) - Defaults to `true`. Indicates whether to prefer speaker output.
* `onConfigureNativeAudio` (function, optional) - A callback function to configure native audio. It receives `trackState` and `preferSpeakerOutput` and returns an `AppleAudioConfiguration`.
### Returns
`void[]`
### Deprecated
This function is deprecated. Use `setupIOSAudioManagement` instead. The `room` parameter is ignored, and the audio session is managed via audio engine events. The `trackState` passed to `onConfigureNativeAudio` is derived from the audio engine's playout/recording state, not publication counts. Callers with nuanced per-state logic should migrate to `setupIOSAudioManagement`.
```
--------------------------------
### Run Unit Tests
Source: https://github.com/livekit/client-sdk-react-native/blob/main/CONTRIBUTING.md
Executes the unit tests for the project using Jest.
```sh
yarn test
```
--------------------------------
### RegisterGlobalsOptions Interface
Source: https://github.com/livekit/client-sdk-react-native/blob/main/docs/interfaces/RegisterGlobalsOptions.html
Interface for configuring global options when initializing the LiveKit React Native SDK. This includes options for automatically configuring the audio session.
```APIDOC
## Interface: RegisterGlobalsOptions
### Description
This interface defines the options available for configuring global settings when initializing the LiveKit React Native SDK. It primarily allows for the automatic configuration of the audio session on iOS.
### Properties
#### `autoConfigureAudioSession`
- **Type**: `boolean`
- **Optional**: Yes
- **Description**: Automatically configure and activate the iOS audio session based on audio engine lifecycle events. Has no effect on non-Apple platforms.
- **Default**: `true`
```
--------------------------------
### Register LiveKit Globals for iOS
Source: https://github.com/livekit/client-sdk-react-native/blob/main/README.md
Automatically configures and activates the audio session for WebRTC audio engine lifecycle events on iOS. This is enabled by default.
```javascript
registerGlobals();
```
--------------------------------
### MultiBandTrackVolumeOptions
Source: https://github.com/livekit/client-sdk-react-native/blob/main/docs/interfaces/MultiBandTrackVolumeOptions.html
Interface for configuring options for the useMultibandTrackVolume hook.
```APIDOC
## Interface: MultiBandTrackVolumeOptions
### Description
Interface for configuring options for the useMultibandTrackVolume hook.
### Properties
#### `bands` (number) - Optional
The number of bands to split the audio into.
#### `maxFrequency` (number) - Optional
Cut off frequency on the higher end.
#### `minFrequency` (number) - Optional
Cut off frequency on the lower end.
#### `updateInterval` (number) - Optional
Update should run every x ms.
```
--------------------------------
### setSifTrailer
Source: https://github.com/livekit/client-sdk-react-native/blob/main/docs/classes/RNKeyProvider.html
Sets the SIF trailer. This is an experimental feature.
```APIDOC
## setSifTrailer()
### Description
Sets the SIF trailer.
### Method
`setSifTrailer`
### Endpoint
N/A (Method call)
### Parameters
* None
### Request Example
```javascript
keyProvider.setSifTrailer();
```
### Response
#### Success Response (200)
* **void** - No return value.
#### Response Example
```json
null
```
```
--------------------------------
### Functions
Source: https://github.com/livekit/client-sdk-react-native/blob/main/docs/modules.html
Provides utility functions and hooks for interacting with LiveKit.
```APIDOC
## Functions
### BarVisualizer
A component for visualizing audio levels.
### getDefaultAppleAudioConfigurationForMode
Gets the default Apple audio configuration for a given mode.
### LiveKitRoom
The main component for setting up a LiveKit room.
### registerGlobals
Registers global settings for the SDK.
### setLogLevel
Sets the log level for the SDK.
### setupIOSAudioManagement
Sets up audio management for iOS.
### sortParticipants
Sorts participants in a room.
### useBarAnimator
A hook for animating bars, likely for visualization.
### useIOSAudioManagement
A hook for managing audio on iOS.
### useMultibandTrackVolume
A hook for controlling multi-band track volume.
### useParticipant
A hook to get participant information.
### useRNE2EEManager
A hook to use the E2E manager.
### useRoom
A hook to get room information.
### useTrackVolume
A hook for track volume control.
### VideoView
A component for displaying video.
```
--------------------------------
### AndroidAudioTypeOptions
Source: https://github.com/livekit/client-sdk-react-native/blob/main/docs/types/AndroidAudioTypeOptions.html
Defines configuration options for audio routing on Android. These options allow fine-grained control over how audio is handled, including content type, usage type, focus modes, and stream types.
```APIDOC
## Type Alias: AndroidAudioTypeOptions
### Description
This type alias defines a set of optional properties for configuring audio behavior specifically for Android devices. It allows developers to specify various audio attributes and modes to control how audio is processed and routed.
### Properties
#### `audioAttributesContentType` (string, optional)
Corresponds to Android's `AudioAttributes` content type. Can be one of: "movie", "music", "sonification", "speech", "unknown". Defaults to 'speech'.
#### `audioAttributesUsageType` (string, optional)
Corresponds to Android's `AudioAttributes` usage type. Can be one of: "alarm", "assistanceAccessibility", "assistanceNavigationGuidance", "assistanceSonification", "assistant", "game", "media", "notification", "notificationEvent", "notificationRingtone", "unknown", "voiceCommunication", "voiceCommunicationSignalling". Defaults to 'voiceCommunication'.
#### `audioFocusMode` (string, optional)
Corresponds to the duration hint when requesting audio focus. Can be one of: "gain", "gainTransient", "gainTransientExclusive", "gainTransientMayDuck". Defaults to 'gain'.
#### `audioMode` (string, optional)
Corresponds to `AudioManager.setMode(int)`. Can be one of: "normal", "callScreening", "inCall", "inCommunication", "ringtone". Defaults to 'inCommunication'.
#### `audioStreamType` (string, optional)
Corresponds to Android's audio stream type. Can be one of: "accessibility", "alarm", "dtmf", "music", "notification", "ring", "system", "voiceCall".
#### `forceHandleAudioRouting` (boolean, optional)
If true, the SDK will attempt to force audio routing.
#### `manageAudioFocus` (boolean, optional)
If true, the SDK will manage audio focus.
### Source
Defined in `src/audio/AudioSession.ts`
```
--------------------------------
### Interfaces
Source: https://github.com/livekit/client-sdk-react-native/blob/main/docs/modules.html
Defines the structure for various props and state objects used in the SDK.
```APIDOC
## Interfaces
### BarVisualizerProps
Props for the BarVisualizer component.
### LiveKitRoomProps
Props for the LiveKitRoom component.
### MultiBandTrackVolumeOptions
Options for configuring multi-band track volume.
### ParticipantState
Represents the state of a participant in a room.
### RegisterGlobalsOptions
Options for registering global settings.
### RNE2EEManagerState
State for the RNE2EEManager.
### RoomOptions
Options for configuring a room.
### RoomState
Represents the overall state of a room.
```
--------------------------------
### BarVisualizer
Source: https://github.com/livekit/client-sdk-react-native/blob/main/docs/functions/BarVisualizer.html
Visualizes audio signals from a TrackReference as bars. If the `state` prop is set, it automatically transitions between VoiceAssistant states. This component is in Beta.
```APIDOC
## BarVisualizer
### Description
Visualizes audio signals from a TrackReference as bars. If the `state` prop is set, it automatically transitions between VoiceAssistant states. For VoiceAssistant state transitions, this component requires a voice assistant agent running with livekit-agents >= 0.9.0.
### Parameters
#### __namedParameters (BarVisualizerProps)
- **state** (VoiceAssistantState | undefined) - Optional - The current state of the voice assistant, used for automatic state transitions.
- **trackRef** (TrackReference | undefined) - Optional - The audio track reference to visualize.
### Returns
Element
```
--------------------------------
### setSifTrailer
Source: https://github.com/livekit/client-sdk-react-native/blob/main/docs/classes/RNKeyProvider.html
Sets the SIF trailer for encryption. This method is experimental.
```APIDOC
## setSifTrailer
### Description
Sets the SIF trailer for encryption. This method is experimental.
### Method
Not applicable (SDK method)
### Endpoint
Not applicable (SDK method)
### Parameters
#### Path Parameters
None
#### Query Parameters
None
#### Request Body
None
### Parameters
* **trailer** (Uint8Array) - Required - The SIF trailer to set.
### Returns
Promise
### Request Example
```javascript
// Assuming you have an instance of RNKeyProvider called keyProvider
const trailerData = new Uint8Array([1, 2, 3, 4]); // Example trailer data
keyProvider.setSifTrailer(trailerData).then(result => {
console.log('SIF trailer set successfully:', result);
}).catch(error => {
console.error('Error setting SIF trailer:', error);
});
```
### Response
#### Success Response
* (any) - The result of setting the SIF trailer. The exact type and value depend on the implementation.
#### Response Example
```json
// Example success response (actual response may vary)
{
"success": true
}
```
```
--------------------------------
### RoomOptions Interface
Source: https://github.com/livekit/client-sdk-react-native/blob/main/docs/interfaces/RoomOptions.html
Defines options for configuring a room, including custom participant sorting.
```APIDOC
## Interface: RoomOptions
### Description
This interface defines configuration options for a LiveKit room. It currently supports a single optional property for custom participant sorting.
### Properties
#### `sortParticipants` (Optional)
- **Type**: `(participants: Participant[]) => void`
- **Description**: A callback function that can be provided to sort the list of participants before they are rendered or processed. It receives an array of `Participant` objects and should not return any value.
```
--------------------------------
### Register LiveKit Globals
Source: https://github.com/livekit/client-sdk-react-native/blob/main/README.md
Call registerGlobals() in your index.js file to set up the required WebRTC libraries for LiveKit to function in a Javascript environment.
```javascript
import { registerGlobals } from '@livekit/react-native';
// ...
registerGlobals();
```
--------------------------------
### useBarAnimator
Source: https://github.com/livekit/client-sdk-react-native/blob/main/docs/functions/useBarAnimator.html
The useBarAnimator hook generates data for a bar visualization based on the provided state, number of columns, and interval.
```APIDOC
## Function useBarAnimator
### Description
Generates data for a bar visualization.
### Parameters
* **state** (AgentState | undefined) - The current state of the agent.
* **columns** (number) - The number of columns for the visualization.
* **interval** (number) - The interval for updating the visualization.
### Returns
* **number[][]** - An array of arrays representing the data for the bar visualization.
```
--------------------------------
### manageAudioFocus
Source: https://github.com/livekit/client-sdk-react-native/blob/main/docs/types/AndroidAudioTypeOptions.html
A boolean flag to determine if LiveKit should automatically manage the audio focus. Defaults to true, meaning LiveKit handles audio focus by default.
```APIDOC
## manageAudioFocus
### Description
Whether LiveKit should handle managing the audio focus or not.
### Type
`boolean`
### Default Value
`true`
```
--------------------------------
### LiveKitRoomProps Interface Definition
Source: https://github.com/livekit/client-sdk-react-native/blob/main/docs/interfaces/LiveKitRoomProps.html
Defines the properties for configuring a LiveKit room component. Includes options for audio, video, screen sharing, connection settings, and event callbacks.
```typescript
interface LiveKitRoomProps {
[audio](#audio)?: boolean | AudioCaptureOptions;
[connect](#connect)?: boolean;
[connectOptions](#connectoptions)?: RoomConnectOptions;
[featureFlags](#featureflags)?: FeatureFlags;
[onConnected](#onconnected)?: () => void;
[onDisconnected](#ondisconnected)?: () => void;
[onEncryptionError](#onencryptionerror)?: (error: Error) => void;
[onError](#onerror)?: (error: Error) => void;
[onMediaDeviceFailure](#onmediadevicefailure)?: (failure?: MediaDeviceFailure) => void;
[options](#options)?: RoomOptions;
[room](#room)?: Room;
[screen](#screen)?: boolean | ScreenShareCaptureOptions;
[serverUrl](#serverurl): string | undefined;
[simulateParticipants](#simulateparticipants)?: number;
[token](#token): string | undefined;
[video](#video)?: boolean | VideoCaptureOptions;
}
```
--------------------------------
### Verify Code with TypeScript and ESLint
Source: https://github.com/livekit/client-sdk-react-native/blob/main/CONTRIBUTING.md
Runs TypeScript for type checking and ESLint for code linting to ensure code quality.
```sh
yarn typescript
yarn lint
```
--------------------------------
### Variables
Source: https://github.com/livekit/client-sdk-react-native/blob/main/docs/modules.html
Exposes constants and variables for SDK usage.
```APIDOC
## Variables
### AndroidAudioTypePresets
Predefined audio type presets for Android.
### log
A logger instance for the SDK.
### VideoTrack
Represents a video track.
```
--------------------------------
### Register LiveKit Globals
Source: https://github.com/livekit/client-sdk-react-native/blob/main/docs/index.html
Initializes the WebRTC libraries required for LiveKit to function in a React Native environment. This must be called before using other LiveKit components.
```javascript
import { registerGlobals } from '@livekit/react-native';
// ...
registerGlobals();
```
--------------------------------
### LiveKitRoomProps
Source: https://github.com/livekit/client-sdk-react-native/blob/main/docs/interfaces/LiveKitRoomProps.html
Props for the LiveKitRoom component.
```APIDOC
## LiveKitRoomProps
Props for the LiveKitRoom component.
### Properties
#### `serverUrl`
- **Type**: `string | undefined`
- **Description**: URL to the LiveKit server. For example: `wss://.livekit.cloud`. `undefined` is accepted as an intermediate value, but a valid string URL is required for connection.
#### `token`
- **Type**: `string | undefined`
- **Description**: User-specific access token for client authentication. A valid string token is required to establish a room connection. `undefined` is accepted as an intermediate value.
- **See**: [https://docs.livekit.io/cloud/project-management/keys-and-tokens/#generating-access-tokens](https://docs.livekit.io/cloud/project-management/keys-and-tokens/#generating-access-tokens)
#### `video`
- **Type**: `boolean | VideoCaptureOptions`
- **Description**: Publish video immediately after connecting. Defaults to `false`.
- **See**: [https://docs.livekit.io/client-sdk-js/interfaces/VideoCaptureOptions.html](https://docs.livekit.io/client-sdk-js/interfaces/VideoCaptureOptions.html)
#### `screen`
- **Type**: `boolean | ScreenShareCaptureOptions`
- **Description**: Publish screen share immediately after connecting. Defaults to `false`.
- **See**: [https://docs.livekit.io/client-sdk-js/interfaces/ScreenShareCaptureOptions.html](https://docs.livekit.io/client-sdk-js/interfaces/ScreenShareCaptureOptions.html)
#### `options`
- **Type**: `RoomOptions`
- **Description**: Options for creating a new room. These options have no effect if a room instance is already provided. Set options directly on the room instance in that case.
- **See**: [https://docs.livekit.io/client-sdk-js/interfaces/RoomOptions.html](https://docs.livekit.io/client-sdk-js/interfaces/RoomOptions.html)
#### `room`
- **Type**: `Room`
- **Description**: Optional room instance. Providing your own room instance overwrites the `options` parameter. Ensure options are set directly on the room instance.
#### `onMediaDeviceFailure`
- **Type**: `(failure?: MediaDeviceFailure) => void`
- **Description**: Callback function for media device failures.
#### `simulateParticipants`
- **Type**: `number`
- **Description**: Number of participants to simulate.
```
--------------------------------
### RoomState Interface
Source: https://github.com/livekit/client-sdk-react-native/blob/main/docs/interfaces/RoomState.html
This interface represents the state of a room, providing access to its audio tracks, participants, and any associated errors or room object.
```APIDOC
## Interface: RoomState
### Description
Represents the state of a room in the LiveKit React Native SDK. It provides access to the current audio tracks, connected participants, and any errors that may have occurred.
### Properties
* **audioTracks** (AudioTrack[]) - An array of audio tracks currently active in the room.
* **error**? (Error) - An optional Error object if any error has occurred within the room state.
* **participants** (Participant[]) - An array of participants currently connected to the room.
* **room**? (Room) - An optional Room object representing the room itself.
```
--------------------------------
### setSifTrailer Method
Source: https://github.com/livekit/client-sdk-react-native/blob/main/docs/classes/RNE2EEManager.html
Sets the SIF trailer for encryption. This method is documented but has no signature or parameters provided in the source.
```APIDOC
## setSifTrailer Method
### Description
Sets the SIF trailer for encryption. This is an experimental feature.
*Note: The source documentation for this method does not include its signature or parameters.*
```
--------------------------------
### MultiBandTrackVolumeOptions Interface Definition
Source: https://github.com/livekit/client-sdk-react-native/blob/main/docs/interfaces/MultiBandTrackVolumeOptions.html
Defines the configuration options for the useMultibandTrackVolume hook, allowing customization of audio band splitting and frequency cutoffs.
```typescript
interface MultiBandTrackVolumeOptions {
[bands](#bands)?: number;
[maxFrequency](#maxfrequency)?: number;
[minFrequency](#minfrequency)?: number;
[updateInterval](#updateinterval)?: number;
}
```
--------------------------------
### showAudioRoutePicker
Source: https://github.com/livekit/client-sdk-react-native/blob/main/docs/classes/AudioSession.html
Displays an AVRoutePickerView for the user to choose their audio output. This feature is only available on iOS 11 and later.
```APIDOC
## showAudioRoutePicker
### Description
Displays an AVRoutePickerView for the user to choose their audio output. This feature is only available on iOS 11 and later.
### Method
Static method
### Endpoint
N/A (This is a native UI presentation)
### Parameters
#### Path Parameters
None
#### Query Parameters
None
#### Request Body
None
### Returns
Promise
### Request Example
```javascript
AudioSession.showAudioRoutePicker();
```
### Response
#### Success Response (void)
This method does not return a value upon success.
#### Response Example
None
```
--------------------------------
### dispose
Source: https://github.com/livekit/client-sdk-react-native/blob/main/docs/classes/RNKeyProvider.html
Disposes of the RNKeyProvider instance. This is an experimental feature.
```APIDOC
## dispose(): void
### Description
Disposes of the RNKeyProvider instance.
### Method
`dispose`
### Endpoint
N/A (Method call)
### Parameters
* None
### Request Example
```javascript
keyProvider.dispose();
```
### Response
#### Success Response (200)
* **void** - No return value.
#### Response Example
```json
null
```
```
--------------------------------
### VideoView
Source: https://github.com/livekit/client-sdk-react-native/blob/main/docs/functions/VideoView.html
The VideoView function renders video tracks. It is deprecated and users should use `VideoTrack` and `VideoTrackProps` instead.
```APIDOC
## VideoView
### Description
Renders video tracks. This component is deprecated.
### Parameters
* `__namedParameters` ([Props](../types/Props.html)) - Description of props for VideoView.
### Returns
Element
### Deprecated
Use `VideoTrack` and `VideoTrackProps` instead.
```
--------------------------------
### AudioConfiguration Type Definition
Source: https://github.com/livekit/client-sdk-react-native/blob/main/docs/types/AudioConfiguration.html
Defines the structure for configuring the audio session, including platform-specific settings for Android and iOS.
```typescript
type AudioConfiguration = {
[android]?:
{
audioTypeOptions: AndroidAudioTypeOptions;
preferredOutputList?: ("speaker" | "earpiece" | "headset" | "bluetooth")[];
};
[ios]?:
{
defaultOutput?: "speaker" | "earpiece"
};
}
```