@100mslive/hms-whiteboard

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

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

原始使用文档
文档目录3 节
  1. Requirements
  2. Opening and Closing the Whiteboard
  3. Displaying the Collaborative Whiteboard

100ms Whiteboard

Lint, Test and Build Bundle Size License Tree shaking

The 100ms SDK provides robust APIs for integrating whiteboard collaboration into your conferencing sessions. Participants can engage in real-time by drawing, writing, and collaborating on a shared digital whiteboard. This documentation outlines how to implement the start and stop functionality for a whiteboard and display it within an iframe or embed it as a React component.

Requirements

  • React 18 or higher
  • Webpack 5 or higher if you're using it to bundle your app
  • User roles must be configured to enable whiteboard functionality via the 100ms dashboard for starting or viewing the whiteboard. Refer here.
  • If you're on React and are not using the @100mslive/roomkit-react package, install the @100mslive/hms-whiteboard package.
yarn add @100mslive/hms-whiteboard

Opening and Closing the Whiteboard

JavaScript users can use the selectPermissions selector which fetches the whiteboard specific permissions array from the local peer's role permissions.

React users can check for the toggle function returned by the utility hook useWhiteboard.

// Vanilla JavaScript Example
import { selectPermissions, selectWhiteboard } from '@100mslive/hms-video-store';

const permissions = hmsStore.getState(selectPermissions)?.whiteboard; // Array<'read' | 'write' | 'admin'>
const isAdmin = !!permissions?.includes('admin');
const whiteboard = hmsStore.getState(selectWhiteboard);
const isOwner = whiteboard?.owner === localPeerUserId;

const toggle = async () => {
    if (!isAdmin) {
        return;
    }

    if (whiteboard?.open) {
        isOwner && (await actions.interactivityCenter.whiteboard.close());
    } else {
        await actions.interactivityCenter.whiteboard.open();
    }
};

// usage
const toggleButton = document.getElementById('toggle-whiteboard');
// non-admin users cannot toggle the whiteboard
toggleButton.disabled = !isAdmin;
toggleButton.onclick = toggle;
// React Example
import React from 'react';
import { useWhiteboard } from '@100mslive/react-sdk';

export const WhiteboardToggle = () => {
    const { toggle, open, isOwner } = useWhiteboard();

    // non-admin users cannot toggle the whiteboard
    if (!toggle) {
        return null;
    }

    return (
        <Button onClick={toggle} active={!open} disabled={open && !isOwner}>
            Toggle Whitboard
        </Button>
    );
};

Displaying the Collaborative Whiteboard

You can display the whiteboard when it's open by embedding it as an iframe or as a React component for more fine-grained controls, if your app is built using React.

// Vanilla JavaScript Example
import { selectWhiteboard } from '@100mslive/hms-video-store';

const whiteboard = hmsStore.subscribe((whiteboard) => {
    if (whiteboard?.open && whiteboard?.url) {
        const whiteboardIframe = document.createElement('iframe');
        whiteboardIframe.src = whiteboard.url;
    } else {
        const whiteboardIframe = document.getElementById('whiteboard');
        whiteboardIframe?.remove();
    }
}, selectWhiteboard);
// React Example
import React from 'react';
import { useWhiteboard } from '@100mslive/react-sdk';
import { Whiteboard } from '@100mslive/hms-whiteboard';
import '@100mslive/hms-whiteboard/index.css';

const WhiteboardEmbed = () => {
    const { token, endpoint } = useWhiteboard();

    if (!token) {
        return null;
    }

    return (
        <div style={{ width: '100%', height: '650px' }}>
            <Whiteboard
                token={token}
                endpoint={`https://${endpoint}`}
                onMount={({ store, editor }) => {
                    console.log(store, editor);
                }}
            />
        </div>
    );
};

Whiteboard related CSS needs to be imported in your app's top level CSS files using @import '@100mslive/hms-whiteboard/index.css';(recommended) or in one of your top level JS file using import '@100mslive/hms-whiteboard/index.css';.

Note that if you're using @100mslive/roomkit-react you'll need to import @100mslive/roomkit-react/index.css accordingly.

版本与发布记录

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

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

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

@100mslive/hms-whiteboard 是什么?

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

如何安装 @100mslive/hms-whiteboard?

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

@100mslive/hms-whiteboard 支持 TypeScript 吗?

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

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

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

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

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

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

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

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

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