@100mslive/react-sdk

中文文档
0.13.3发布于 2026/10/01MITTypeScriptESM + CJS构建来源已验证近 30 天下载 18万

Lint, Test and Build [![Bundle Size](https://badgen.net/bundlephobia/minzip/@100mslive

原始使用文档
文档目录4 节
  1. Installation
  2. Usage
  3. Primitive Hooks
  4. Helpful Hooks

100ms React SDK

Lint, Test and Build Bundle Size License Tree shaking

This package is a react wrapper over the core SDK(@100mslive/hms-video-store). An easy way to use the store, actions and notifications are provided via React hooks. Some other hooks are also provided for ease of use which wrap over the primitive ones. If someone is using class based react components, they'll be better off with using the core sdk directly.

Installation

// npm
npm install @100mslive/react-sdk@latest --save

// yarn
yarn add @100mslive/react-sdk@latest

Usage

Add HMSRoomProvider from @100mslive/react-sdk at the top level of your component tree where you want to use the hooks. Wihout this the hooks will throw an error.

<HMSRoomProvider>
   <YourComponent></YourComponent>
</HMSRoomProvider>

By default, when using HMSRoomProvider room leave will be called when you are leaving/closing the tab. To disable this behaviour, you can pass leaveOnUnload as false

NOTE: The above leave might or might not be successfully sent to server as it depends on the browser implementation. This works on chromium based browsers.

Primitive Hooks

These are hooks wrapper over the sdk things.

  • useHMSStore - to get any state from store
  • useHMSActions - hmsActions to perform any actions
  • useHMSNotifications - to receive any new notifications/error for the room
  • useHMSVanillaStore - return the store object directly to be used in non react context
  • useHMSStatsStore - to get webrtc related stats

Helpful Hooks

  • useVideo - attaching and detaching video based on trackId
  • useVideoList - helpful to build a paginated gallery view of video tiles
  • useScreenShare - to toggle screenshare
  • useCustomEvent - to add custom events
  • useDevices - returns a list of all A/V devices
  • useParticipants - get count of participants, participants filtered by role or metadata
  • usePreviewJoin - implementing preview + join
  • useAVToggle - to toggle mute/unmute for audio and video
  • useRemoteAVToggle - to toggle remote mute/unmute + audio volume changer on tile level
  • useAutoplayError - unblock browser autoplay block
  • useAudioLevelStyles - apply css properties on element based on it's audio level

Refer to docs for a more detailed guide.

版本与发布记录

@100mslive/react-sdk 共发布 671 个版本,首次发布于 2021/11/13;过去 12 个月发布了 81 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
0.13.3latest2026/10/011 个月前
0.13.3-alpha.1alpha2026/10/011 个月前
0.13.3-alpha.02026/09/291 个月前
0.13.22026/09/221 个月前
0.13.2-alpha.62026/09/221 个月前
0.13.2-alpha.52026/09/221 个月前

其他发布通道:experimental → 0.6.4-alpha.0,alpha → 0.13.3-alpha.1。

关于 @100mslive/react-sdk 的常见问题

@100mslive/react-sdk 是什么?

[![Bundle Size](https://badgen.net/bundlephobia/minzip/@100mslive

如何安装 @100mslive/react-sdk?

在项目目录运行 npm install @100mslive/react-sdk,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:react(>=16.8 <19.0.0)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@100mslive/react-sdk 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@100mslive/react-sdk 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@100mslive/react-sdk 可以商用吗?

@100mslive/react-sdk 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@100mslive/react-sdk 的下载量有多少?

根据 npm 官方下载统计,@100mslive/react-sdk 在 2026/10/04 – 2026/11/02 这 30 天内被下载 180,367 次,日均约 6,012 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@100mslive/react-sdk 还在维护吗?

最新版本 0.13.3 发布于 2026/10/01(1 个月前);至今共发布 671 个版本,其中过去 12 个月发布了 81 个;首次发布于 2021/11/13。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。