百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
1

100ms-react-native

> 前端框架
开源

React Native 直播、视频会议 SDK 和示例应用

100 stars0 点赞2 次浏览
访问官网GitHub

工具介绍

React Native 直播、视频会议 SDK 和示例应用

100ms React Native SDK

Integrate Real Time Audio and Video conferencing, Interactive Live Streaming, and Chat in your apps with 100ms React Native SDK.

With support for HLS and RTMP Live Streaming and Recording, Picture-in-Picture (PiP), one-to-one Video Call Modes, Audio Rooms, Video Player and much more, add immersive real-time communications to your apps.

Package Version
@100mslive/react-native-room-kit
@100mslive/react-native-hms
@100mslive/react-native-video-plugin

Read the Complete Documentation here: https://www.100ms.live/docs/react-native/v2/foundation/basics

Example App

Download the Example iOS app here: https://testflight.apple.com/join/v4bSIPad

Download the Example Android app here: https://appdistribution.firebase.dev/i/7b7ab3b30e627c35

To get a better understanding of how the example app is structured, what to do on onJoin, onTrack and onPeer listeners, creating PeerTrackNodes, how to use Redux, and what type of layouts and sorting you can implement in your app, checkout Example App's README

To run the Example app on your system, follow these steps -

  1. In the project root, run npm install
  2. Go to the example folder, cd example
  3. In the example folder, run npm install
  4. To run on Android, run npx react-native run-android
  5. To run on iOS, first install the pods in iOS folder, cd ios; pod install. Then, set the Correct Development Team in Xcode Signing & Capabilities section. Then, in example folder, run npx react-native run-ios

Troubleshooting Guide for resolving issues in running the Example app is available here.

☝️ Minimum Configuration

  • Support for React Native 0.73.0 or above
  • Support for Java 17 or above
  • Support for Android API level 24 or above
  • Xcode 14 or above
  • Support for iOS 16 or above
  • Node.js 22 or above

Recommended Configuration

  • React Native 0.77.3 or above
  • Java 17 or above
  • Android API level 35 or above
  • Xcode 15 or above
  • iOS 16 or above
  • Node.js 22 or above

Supported Devices

  • The Android SDK supports Android API level 24 (Android 7.0) and higher. It is built for arm64-v8a and x86_64 architectures (64-bit only). Devices running Android OS 11 or above is recommended.

  • iPhone & iPads with iOS version 16 or above are supported.

Installation

bash
npm install @100mslive/react-native-hms --save

Download the Sample iOS App here: https://testflight.apple.com/join/v4bSIPad

Download the Sample Android App here: https://appdistribution.firebase.dev/i/7b7ab3b30e627c35

More information about Integrating the SDK is available here.

Permissions

For iOS Permissions

Add following lines in Info.plist file

xml
NSCameraUsageDescription
Please allow access to Camera to enable video conferencing
NSMicrophoneUsageDescription
Please allow access to Microphone to enable video conferencing
NSLocalNetworkUsageDescription
Please allow access to network usage to enable video conferencing

For Android Permissions

Add following permissions in AndroidManifest.xml

xml

You will also need to request Camera and Record Audio permissions at runtime before you join a call or display a preview. Please follow Android Documentation for runtime permissions.

We suggest using react-native-permission to acquire permissions from both platforms.

More information about Audio Video Permission on iOS & Android is available here.

QuickStart

The package exports all the classes and a HMSSDK class that manages everything.

Setting up the HMS Instance

First invoke the build method which returns an instance of HMSSDK. Save this instance to perform all actions related to 100ms.

typescript
import { HMSSDK } from "@100mslive/react-native-hms";

/**
 * create HMSSDK instance using the build method & save it for further usage
 *
 * Important Note: Don't build new `HMSSDK` instance before destroying the previous one.
 * for more info checkout {@link https://www.100ms.live/docs/react-native/v2/how--to-guides/install-the-sdk/hmssdk#what-does-destroy-method-do}
 */
const hmsInstance = await HMSSDK.build();

Get Authentication Token

Fetch token using room-code method (Recommended)

We can get the authentication token using room-code from meeting URL.

Let's understand the subdomain and code from the sample URL

In this sample url: http://100ms-rocks.app.100ms.live/meeting/abc-defg-hij

  • Subdomain is 100ms-rocks
  • Room code is abc-defg-hij

Now to get the room-code from meeting URL, we can write our own logic or use the getCode method from here

To generate token we will be using getAuthTokenByRoomCode method available on HMSSDK instance. This method has roomCode as a required parameter and userId & endpoint as optional parameter.

Let's checkout the implementation:

javascript
/**
 * `getAuthTokenByRoomCode` returns a promise which is resolved with "auth token"
 * checkout {@link https://www.100ms.live/docs/react-native/v2/how--to-guides/install-the-sdk/hmssdk#what-does-destroy-method-do}
 */
const token = await hmsInstance.getAuthTokenByRoomCode("YOUR_ROOM_CODE");

/**
 * Create `HMSConfig` with the above auth token and username
 */
const hmsConfig = new HMSConfig({
  authToken: token,
  username: "John Appleseed",
});

Get temporary token from dashboard

To test audio/video functionality, you need to connect to a 100ms Room. Please check the following steps for the same -

  1. Navigate to your 100ms dashboard or create an account if you don't have one.
  2. Use the Video Conferencing Starter Kit to create a room with a default template assigned to it to test this app quickly.
  3. Go to the Rooms page in your dashboard, click on the Room Id of the room you created above, and click on the Join Room button on the top right.
  4. You will see 100ms demo URLs for the roles created when you deployed the starter kit; you can click on the 'key' icon to copy the token and update the AUTH_TOKEN variable in "App.js" file.

    Token from 100ms dashboard is for testing purposes only, For production applications you must generate tokens on your own server. Refer to the Management Token section in Authentication and Tokens guide for more information.

Add Event Listeners

Add Event Listeners to get notified about actions happening in the 100ms Room.

The most commonly used Events are onJoin, onPeerUpdate & onTrackUpdate. All the available actions can be found in the HMSUpdateListenerActions class.

The Event Listeners are to be used for handling any update happening in 100ms Room.

typescript
const hmsInstance = await HMSSDK.build();

// instance acquired from build() method
hmsInstance.addEventListener(
  HMSUpdateListenerActions.ON_JOIN,
  joinSuccess, // function that will be called Joining a Room is successful
);

The detailed QuickStart Guide is available here.

Join the Room

To interact with peers in audio or video call, the user needs to Join a Room.

When user indicates that they want to join the room, your app should have -

  1. User Name - The name which should be displayed to other peers in the room.

  2. Authentication Token - The Client side Authentication Token generated by the Token Service. Details about how to create Auth Tokens are available here.

Additionally, you can also pass these fields while Joining a Room -

  1. Track Settings - Such as joining a Room with Muted Audio or Video using the HMSTrackSettings object. More information is available here.

  2. Peer Metadata - This can be used to pass any additional metadata associated with the user using metadata of HMSConfig object. For Eg: user-id mapping at the application side. More information is available here.

NOTE: ON_JOIN Event Listener must be attached before calling join function to receive the event callback.

…

More information about Joining a Room is available here.

Basic Mechanism of using 100ms APIs

For invoking any actions simply use the HMSSDK instance created in above steps. Few common examples of using it are as follows -

typescript
// To Mute Audio of local peer - other peers will stop hearing audio
hmsInstance?.localPeer?.localAudioTrack()?.setMute(true);

// To Mute Video of local peer - other peers will stop seeing video
hmsInstance?.localPeer?.localVideoTrack()?.setMute(true);

// Switch Camera from Front to Back or vice-versa
hmsInstance?.localPeer?.localVideoTrack()?.switchCamera();

// Leave the ongoing Room (async function)
await hmsInstance?.leave();

// To send a Chat Message to all peers in Room
await hmsInstance?.sendBroadcastMessage("Hello Everyone! ");

More information about using HMSSDK APIs is available here.

Viewing the Video

It all comes down to this. All the setup so far has been done so that we can show Live Streaming Video in our beautiful apps.

100ms React Native SDK provides HmsView component that renders the video on the screen. You can access HmsView from the HMSSDK instance created in above steps.

We simply have to pass a Video Track's trackId to the HmsView to begin automatic rendering of Live Video Stream.

We can also optionally pass props like key, scaleType, mirror to customize the HmsView component.

typescript
// get HmsView from the HMSSDK instance created earlier
const HmsView = hmsInstance.HmsView;

;

const styles = StyleSheet.create({
  hmsView: {
    height: "100%",
    width: "100%",
  },
});
  • One HmsView component can only be connected with one video trackId. To display multiple videos you have to create multiple instances of HmsView component.

  • It's recommended to always pass the key property while creating HmsView. If a nul

Issues· 2 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

TypeScriptaudioconferenceffmpeghacktoberfest

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月18日
分类前端框架
定价开源

> 相关工具

R
React
用于构建用户界面的 JavaScript 库
V
Vue.js
渐进式 JavaScript 框架
N
Next.js
基于 React 的全栈 Web 框架