@100mslive/hms-video-store

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

@100mslive Core SDK which abstracts the complexities of webRTC while providing a reactive store for data management with a unidirectional data flow

原始使用文档
文档目录7 节
  1. Installation
  2. How To Use
  3. Framework specific wrappers
  4. React
  5. Out of Box Support for Redux Devtools Extension
  6. Store State
  7. Store Graph

100ms Web SDK

NPM Lint, Test and Build Bundle Size License Tree shaking

Architecture

This is the core sdk helping you power your live interactions using 100ms. It abstracts away the intricacies of data management and provides a flux based reactive data store where data flows in only one direction.

The complexity of managing the state of a room is not a trivial task and can spiral out of control very fast. For example, multiple UI components can be interested in a simple data point such as whether the user is currently muted. The mute action itself can be taken from multiple different places in the UI or even by a remote participant. Local states and improper handling of actions or missing corner cases, state duplication etc. have a high potential to make the data mutually inconsistent and out of sync with the source of truth.

Check the SDK Mental Model to build a mental model of how everything works and what all the SDK abstracts away.

There are two important pieces, store for what you want to show and actions for what you want to do -

  1. Store - The core store interface for reading data usually using selectors. The store acts as a single source of truth for any data related to the room. There are two exposed functions -
    • getState(selector) -> get the current state of the UI, true at the time of function call
    • subscribe(callback, selector) -> subscribe to a portion of the state selected by the passed in selector such that whenever the portion changes, the passed in callback is notified.
  2. Actions - The actions interface for dispatching actions which in turn may reach out to server and update the store. Check the interface with detailed doc here.

We also provide optimized and efficient selectors for most common use cases. These are available in this folder.

Important Note: The data received from either getState or Subscribe is immutable, the object received is frozen, and it is not allowed to mutate it. You'll get an error if you try to mutate this data in any way. Immutability of the store is how we ensure it to be consistent and reflect the truth at any point of time.

Installation

yarn add @100mslive/hms-video-store

How To Use

const hms = new HMSReactiveStore();
const hmsActions = hms.getHMSActions();
const hmsStore = hms.getStore();

const toggleAudio = () => {
    const isEnabled = hmsStore.getState(selectIsLocalAudioEnabled);
    hmsActions.setLocalAudioEnabled(!isEnabled);
}

const onSpeakerUpdate = (speaker, prevSpeaker) => {
    console.log("speaker changed from - ", prevSpeaker, ", to - ", speaker);
}

hmsStore.subscribe(onSpeakerUpdate, selectDominantSpeaker);

Framework specific wrappers

Most of the popular javascript frameworks are reactive in nature and have some kind of associated concept which can simplify development further.

React

We provide two hooks one for reading for the store and another for taking actions. We provide a HMSRoomProvider component which takes care of initialization and making these hooks available to your UI components.

function join() {
    const isConnected = useHMSStore(selectIsConnectedToRoom);
    const hmsActions = useHMSActions();

    return <>
        {
            !isConnected &&
            <Button onClick={() => hmsActions.join()}>Join</Button>
        }
    </>
}

Check more over at react-sdk and the docs.

Out of Box Support for Redux Devtools Extension

Store State

Store State

Store Graph

Store State

Refer to docs for more detailed guide

版本与发布记录

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

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

其他发布通道:testingAG → 0.0.29-1003,beta → 0.2.81-aplha.0,experimental → 0.8.4-alpha.0,alpha → 0.15.3-alpha.1。

关于 @100mslive/hms-video-store 的常见问题

@100mslive/hms-video-store 是什么?

@100mslive Core SDK which abstracts the complexities of webRTC while providing a reactive store for data management with a unidirectional data flow

如何安装 @100mslive/hms-video-store?

在项目目录运行 npm install @100mslive/hms-video-store,或使用 pnpm add / yarn add / bun add。

@100mslive/hms-video-store 支持 TypeScript 吗?

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

@100mslive/hms-video-store 支持 ESM 还是 CommonJS?

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

@100mslive/hms-video-store 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=12。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@100mslive/hms-video-store 可以商用吗?

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

@100mslive/hms-video-store 的下载量有多少?

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

@100mslive/hms-video-store 还在维护吗?

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