@digitalsamba/embedded-sdk

中文文档
0.0.58发布于 2026/10/10BSD-2-ClauseTypeScriptESM + CJS构建来源已验证近 30 天下载 1.6万

Digital Samba Embedded SDK - control easily with JS your iframe integration.

原始使用文档
文档目录10 节
  1. Usage with NPM
  2. Initialization
  3. Secure context
  4. Configuring SDK instance
  5. InitOptions
  6. InstanceProperties
  7. Usage
  8. Events
  9. Commands
  10. Examples

Description

Digital Samba Embedded SDK - control easily with JS your iframe integration.

Usage with NPM

Add it to dependency list using your preferred package manager:

npm install @digitalsamba/embedded-sdk

or

yarn install @digitalsamba/embedded-sdk

NPM Package link

After installation, use it in your application code using provided import:

const DigitalSambaEmbedded = require('@digitalsamba/embedded-sdk');

// or, using imports
import DigitalSambaEmbedded from '@digitalsamba/embedded-sdk';

This package is written in TypeScript, so type definitions are also available:

import { SendMessageType, ReceiveMessageType /* ...etc */ } from '@digitalsamba/embedded-sdk';

Initialization


Secure context

️Since the embedded app relies on media device capabilities, it needs to be accessed in a secure context (https:// versus http://).

For local development, most browsers treat http://localhost and http://127.0.0.1 as secure.


Configuring SDK instance

Library provides alternative initialization styles. Using the class constructor you can configure it and load the frame in one call:

const api = new DigitalSambaEmbedded(InitOptions, InstanceProperties /* optional */);

or you can pre-configure the instance and then load it on-demand:

// notice `createControl` vs constructor call
const api = DigitalSambaEmbedded.createControl(InitOptions);

// ...
// when necessary, load the frame:
api.load(InstanceProperties /* optional */);

InitOptions

InitOptions has the following fields:

  • root - HTMLElement. If specified, target frame will be created within it.
  • frame - HTMLIFrameElement to be wrapped.
  • url - full URL to be applied as frame src. Must include protocol and token query param for private rooms;
  • team - team name string
  • room - room identifier string
  • token - optional string for authentication, mainly for private rooms

To successfully initialize an instance of the wrapper one of following combinations needs to be used:

  • root + team + room - will create a controlled frame inside root element
  • frame + team + room - will attach to existing frame
  • frame - will attach to existing frame (assuming you've manually specified correct frame src)
  • root + url - will create a frame inside root element

Remember to always specify allow="camera; microphone; display-capture; autoplay;" and allowFullscreen="true" attributes on iframe if you want to wrap around an existing iframe.

InstanceProperties

  • frameAttributes - list of attributes to be applied to target iframe
  • reportErrors - boolean, false by default. Whether to report misconfiguration or runtime errors to console

Usage

Once initialized you can listen to events emitted by embedded app and control it by sending commands.

Additional functionality like room permission management and exposed state is also available.

Events

To listen for events, attach listener for any of supported events:

api.on('userJoined', (data) => {
  // ...
});

💡 See the events docs for a full list of available events.


Error event can provide useful details:

api.on('appError', (error) => {
  console.log(error);

  /* outputs  {
      name: 'not-allowed',
      message:
        'Recording disabled. You’ll need to edit this room’s properties to record sessions in this room',
      data: {
        type: 'recording'
      }
    },
  */
});

For debugging purposes, you can also listen to all events simultaneously

api.on('*', (data) => {
  console.log(data);
});

Commands

To send commands, api instance provides handy utilities:

api.toggleVideo();
// ...
api.disableAudio();

💡 Full list of available commands with usage examples can be found on documentation website.

Examples

There are several demos available with example integrations

  • Simple Videoroom - simple demo that showcases basic integration, listening to events and running commands
  • Initial settings - examples of setting default settings prior to loading the frame
  • Managed State demo - shows how to use exposed state in complex scenarios, listening to events, checking for permissions and accessing stored data.

版本与发布记录

@digitalsamba/embedded-sdk 共发布 50 个版本,首次发布于 2022/10/27;过去 12 个月发布了 6 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
0.0.58latest2026/10/101 个月前
0.0.572026/07/203 个月前
0.0.562026/07/183 个月前
0.0.552026/04/256 个月前
0.0.542026/02/148 个月前
0.0.532026/01/199 个月前

关于 @digitalsamba/embedded-sdk 的常见问题

@digitalsamba/embedded-sdk 是什么?

Digital Samba Embedded SDK - control easily with JS your iframe integration.

如何安装 @digitalsamba/embedded-sdk?

在项目目录运行 npm install @digitalsamba/embedded-sdk,或使用 pnpm add / yarn add / bun add。

@digitalsamba/embedded-sdk 支持 TypeScript 吗?

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

@digitalsamba/embedded-sdk 支持 ESM 还是 CommonJS?

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

@digitalsamba/embedded-sdk 可以商用吗?

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

@digitalsamba/embedded-sdk 的下载量有多少?

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

@digitalsamba/embedded-sdk 还在维护吗?

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