Package: @digitalsamba/embedded-sdk
Version: 0.0.55
License: BSD-2-Clause
npm install @digitalsamba/embedded-sdkOr via CDN:
<script src="https://unpkg.com/@digitalsamba/embedded-sdk"></script>Production recommendation: Bundle the SDK into your application rather than fetching from npm/CDN at runtime. npm and CDN outages can break your app's availability. Use your bundler (webpack, vite, esbuild) to include it in your production build.
The SDK requires a secure context (HTTPS). Local development accepts:
http://localhosthttp://127.0.0.1
import DigitalSambaEmbedded from '@digitalsamba/embedded-sdk';
const sambaFrame = new DigitalSambaEmbedded({
url: 'https://team.digitalsamba.com/room?token=xxx',
root: document.getElementById('video-container')
});const sambaFrame = DigitalSambaEmbedded.createControl({
url: 'https://team.digitalsamba.com/room?token=xxx',
root: document.getElementById('video-container')
});
// Configure before loading
sambaFrame.on('userJoined', handleJoin);
// Load when ready
sambaFrame.load();const sambaFrame = DigitalSambaEmbedded.createControl({
frame: document.getElementById('existing-iframe')
});| Option | Type | Description |
|---|---|---|
url |
string | Full iframe URL with token |
root |
HTMLElement | Container element for iframe |
frame |
HTMLIFrameElement | Existing iframe to control |
team |
string | Team identifier (alternative to url) |
room |
string | Room identifier (alternative to url) |
token |
string | JWT token (alternative to url) |
roomSettings |
object | Room settings overrides (see below) |
roomSettings options:
| Option | Type | Description |
|---|---|---|
baseDomain |
string | Override base domain |
publicRoomUrl |
string | Override public room URL used for invitation links |
mobileScreenshare |
boolean | Enable mobile screenshare |
videoEnabled |
boolean | Start with camera on/off |
audioEnabled |
boolean | Start with mic on/off |
username |
string | Override display name |
initials |
string | Override avatar initials |
layoutMode |
'auto' | 'tiled' |
Starting layout mode |
showToolbar |
boolean | Show/hide toolbar |
showTopbar |
boolean | Show/hide topbar |
joinScreenEnabled |
boolean | Show/hide the join screen (name/device entry) before entering the room |
showCaptions |
boolean | Show captions initially |
virtualBackground |
object | Pre-configure virtual background |
virtualBackgrounds |
array | Custom background options |
replaceVirtualBackgrounds |
boolean | Replace default backgrounds |
appLanguage |
string | UI language |
muteFrame |
boolean | Start with frame muted |
mediaDevices |
object | Pre-select audio/video devices |
requireRemoveUserConfirmation |
boolean | Confirm before removing users |
Current user information.
const user = sambaFrame.localUser;
// {
// id: "08c82f56-c670-4d36-bfe3-87a8cd0f7f29",
// name: "John",
// avatarColor: "#90c695",
// role: "moderator",
// kind: "local"
// }Available room features (boolean flags).
console.log(sambaFrame.features.chat); // true
console.log(sambaFrame.features.recordings); // true
console.log(sambaFrame.features.screenshare); // trueAvailable features:
chatendSessionfullScreenlanguageSelectionminimizeOwnTileparticipantsListpinscreensharerecordingsvirtualBackgroundsraiseHandinviteqacontentLibrarywhiteboardcaptions
Current room state.
interface RoomState {
appLanguage: string;
audioOnly: boolean;
frameMuted: boolean;
media: {
videoEnabled: boolean;
audioEnabled: boolean;
activeDevices: {
videoinput: string;
audioinput: string;
audiooutput: string;
}
};
layout: {
mode: 'auto' | 'tiled';
showToolbar: boolean;
showTopbar: boolean;
toolbarPosition: 'left' | 'right' | 'bottom';
localTileMinimized: boolean;
contentMode?: 'maximize' | 'pin';
content?: { userId: string; type: string };
};
captionsState: {
showCaptions: boolean;
spokenLanguage: string;
fontSize: 'small' | 'medium' | 'large';
};
virtualBackground: {
enabled: boolean;
enforced?: boolean;
type?: 'blur' | 'image' | 'imageUrl';
name?: string;
value?: string;
};
}Check user permissions.
// Check single permission
const canBroadcast = sambaFrame.permissionManager.hasPermissions('broadcast');
// Check multiple permissions
const canModerate = sambaFrame.permissionManager.hasPermissions([
'remoteMuting',
'removeParticipant'
]);
// Check for specific role
const moderatorCanRecord = sambaFrame.permissionManager.hasPermissions(
'recording',
{ targetRole: 'moderator' }
);Permission Types:
broadcast- Send audio/videomanageBroadcast- Control others' broadcastendSession- End meeting for allstartSession- Start meetingremoveParticipant- Kick usersscreenshare- Share screenmanageScreenshare- Control others' screensharerecording- Start/stop recordinggeneralChat- Send chat messagesremoteMuting- Mute other usersaskRemoteUnmute- Request unmuteraiseHand- Raise handmanageRoles- Change user rolesinviteParticipant- Invite users to roomseeParticipantsPanel- View participants listcontrolRoomEntry- Control room entry (lobby)editWhiteboard- Edit whiteboard content
// Subscribe to recurring events
sambaFrame.on('userJoined', (event) => {
console.log(`${event.data.name} joined`);
});
// One-time subscription
sambaFrame.once('frameLoaded', () => {
console.log('Frame ready');
});
// Unsubscribe
sambaFrame.off('userJoined', handlerFunction);
// Debug: log all events
sambaFrame.on('*', (event) => {
console.log(event.type, event.data);
});| Event | Payload | Description |
|---|---|---|
frameLoaded |
- | iframe loaded and ready |
userJoined |
{ id, name, role } |
Local user joined room |
userLeft |
{ id, name } |
User left room |
usersUpdated |
User[] |
Participant list changed |
sessionEnded |
- | Meeting ended |
| Event | Payload | Description |
|---|---|---|
audioEnabled |
- | Local mic turned on |
audioDisabled |
- | Local mic turned off |
videoEnabled |
- | Local camera turned on |
videoDisabled |
- | Local camera turned off |
screenshareStarted |
{ userId } |
Screen sharing began |
screenshareStopped |
{ userId } |
Screen sharing ended |
activeSpeakerChanged |
{ userId } |
Active speaker changed |
speakerStoppedTalking |
{ userId } |
Speaker went silent |
mediaDeviceChanged |
{ type, deviceId } |
Device selection changed |
| Event | Payload | Description |
|---|---|---|
recordingStarted |
- | Recording began |
recordingStopped |
- | Recording ended |
recordingFailed |
{ error } |
Recording error |
| Event | Payload | Description |
|---|---|---|
layoutModeChanged |
{ mode } |
Layout changed |
appLanguageChanged |
{ language } |
UI language changed |
roomStateUpdated |
RoomState |
Any room state changed |
featureSetUpdated |
FeatureSet |
Available features changed |
| Event | Payload | Description |
|---|---|---|
localTileMaximized |
- | Local tile was maximized |
localTileMinimized |
- | Local tile was minimized |
userMaximized |
{ userId, type, mode } |
User tile maximized/pinned |
| Event | Payload | Description |
|---|---|---|
captionsEnabled |
- | Captions turned on |
captionsDisabled |
- | Captions turned off |
captionsFontSizeChanged |
{ size } |
Caption size changed |
captionsSpokenLanguageChanged |
{ language } |
Spoken language changed |
| Event | Payload | Description |
|---|---|---|
handRaised |
{ userId } |
User raised hand |
handLowered |
{ userId } |
User lowered hand |
chatMessageReceived |
{ message, userId } |
Chat message received |
roleChanged |
{ userId, role } |
User role changed |
permissionsChanged |
{ permissions } |
Permissions updated |
| Event | Payload | Description |
|---|---|---|
virtualBackgroundChanged |
{ type, value } |
Background changed |
virtualBackgroundDisabled |
- | Background disabled |
| Event | Payload | Description |
|---|---|---|
appError |
{ code, message } |
Application error |
mediaConnectionFailed |
- | Media connection to the SFU could not be established (e.g. network/firewall issue) |
mediaPermissionsFailed |
- | Browser denied media device access |
Every SDK method at a glance. Use exact names below — see detailed docs in sections that follow.
| Category | Method | Description |
|---|---|---|
| Lifecycle | load() |
Load the iframe (deferred mode) |
| Lifecycle | leaveSession() |
Leave the session |
| Lifecycle | endSession(showConfirm?) |
End session for all participants |
| Video | enableVideo() |
Turn camera on |
| Video | disableVideo() |
Turn camera off |
| Video | toggleVideo(force?) |
Toggle or force camera state |
| Audio | enableAudio() |
Turn mic on |
| Audio | disableAudio() |
Turn mic off |
| Audio | toggleAudio(force?) |
Toggle or force mic state |
| Screenshare | startScreenshare() |
Start screen sharing |
| Screenshare | stopScreenshare() |
Stop screen sharing |
| Recording | startRecording() |
Start recording |
| Recording | stopRecording() |
Stop recording |
| Restreaming | startRestreaming() |
Start RTMP restreaming |
| Restreaming | stopRestreaming() |
Stop RTMP restreaming |
| Users | listUsers() |
Get all participants |
| Users | getUser(userId) |
Get specific participant |
| Users | removeUser(userId) |
Remove participant from room |
| Users | changeRole(userId, role) |
Change participant's role |
| Moderation | requestMute(userId) |
Request user mute |
| Moderation | requestUnmute(userId) |
Request user unmute |
| Moderation | requestToggleAudio(userId, force?) |
Toggle user's audio |
| Broadcast | allowBroadcast(userId|options) |
Grant broadcast permission |
| Broadcast | disallowBroadcast(userId) |
Revoke broadcast permission |
| Broadcast | allowScreenshare(userId) |
Grant screenshare permission |
| Broadcast | disallowScreenshare(userId) |
Revoke screenshare permission |
| Hand Raise | raiseHand() |
Raise own hand |
| Hand Raise | lowerHand(userId?) |
Lower hand (own or other's) |
| Toolbar | showToolbar() |
Show toolbar |
| Toolbar | hideToolbar() |
Hide toolbar |
| Toolbar | toggleToolbar() |
Toggle toolbar visibility |
| Toolbar | changeToolbarPosition(pos) |
Move toolbar: 'left'|'right'|'bottom' |
| Topbar | showTopbar() |
Show topbar |
| Topbar | hideTopbar() |
Hide topbar |
| Topbar | toggleTopbar() |
Toggle topbar visibility |
| Layout | changeLayoutMode(mode) |
Set layout: 'auto'|'tiled' |
| Tiles | pinUser(userId, type?) |
Pin user's video tile |
| Tiles | unpinUser() |
Unpin current pinned tile |
| Tiles | maximizeUser(userId, type?) |
Maximize user's video tile |
| Tiles | minimizeUser() |
Minimize maximized tile |
| Tiles | minimizeLocalTile() |
Minimize own tile |
| Tiles | maximizeLocalTile() |
Maximize own tile |
| Tiles | minimizeContent() |
Minimize pinned/maximized content |
| Frame Audio | muteFrame() |
Mute all iframe audio output |
| Frame Audio | unmuteFrame() |
Unmute iframe audio output |
| Frame Audio | toggleMuteFrame() |
Toggle iframe audio mute |
| Captions | showCaptions() |
Show captions |
| Captions | hideCaptions() |
Hide captions |
| Captions | toggleCaptions() |
Toggle captions |
| Captions | configureCaptions(options) |
Set font size, language, apply to all |
| Virtual BG | enableVirtualBackground(options) |
Enable blur, image, or imageUrl background |
| Virtual BG | disableVirtualBackground() |
Disable virtual background |
| Virtual BG | configureVirtualBackground(options) |
Configure without enabling |
| Whiteboard | createWhiteboard(options) |
Create new whiteboard |
| Whiteboard | openWhiteboard(id) |
Open whiteboard |
| Whiteboard | closeWhiteboard(id) |
Close whiteboard |
| Whiteboard | toggleWhiteboard() |
Toggle whiteboard |
| Whiteboard | addImageToWhiteboard(options) |
Add image via URL or base64 |
| Library | openLibraryFile(fileId) |
Open library file |
| Library | closeLibraryFile(fileId) |
Close library file |
| Library | toggleLibraryFile(fileId) |
Toggle library file |
| Features | featureEnabled(name) |
Check if feature is enabled |
| Custom Tiles | addCustomTile(options) |
Add custom HTML tile |
| Custom Tiles | removeCustomTile(name) |
Remove custom tile |
| Custom Tiles | sendMessageToCustomTile(options) |
Send data to custom tile |
| Tile Actions | addTileAction(id, props, callback) |
Add custom tile menu action |
| Tile Actions | removeTileAction(id) |
Remove custom tile action |
| UI Callbacks | addUICallback(event, callback) |
Override UI interaction |
| UI Callbacks | removeUICallback(event, callback) |
Remove UI override |
| Frame Events | addFrameEventListener(event, target, handler) |
Listen to iframe JS events |
| Frame Events | removeFrameEventListener(event, target, handler) |
Remove iframe listener |
| Branding | changeBrandingOptions(options) |
Change theme/colors at runtime |
| Events | on(event, handler) |
Subscribe to event |
| Events | once(event, handler) |
One-time event subscription |
| Events | off(event, handler) |
Unsubscribe from event |
// Video
sambaFrame.enableVideo();
sambaFrame.disableVideo();
sambaFrame.toggleVideo(); // Toggle current state
sambaFrame.toggleVideo(true); // Force enable
// Audio
sambaFrame.enableAudio();
sambaFrame.disableAudio();
sambaFrame.toggleAudio();
sambaFrame.toggleAudio(false); // Force disable
// Screen sharing
sambaFrame.startScreenshare();
sambaFrame.stopScreenshare();
// Recording
sambaFrame.startRecording();
sambaFrame.stopRecording();
// Restreaming (RTMP)
sambaFrame.startRestreaming();
sambaFrame.stopRestreaming();// List all users
const users = sambaFrame.listUsers();
// Get specific user
const user = sambaFrame.getUser('user-id');
// Remove user from room
sambaFrame.removeUser('user-id');
// Change user's role
sambaFrame.changeRole('user-id', 'speaker');
// Mute requests
sambaFrame.requestMute('user-id');
sambaFrame.requestUnmute('user-id');
sambaFrame.requestToggleAudio('user-id');
sambaFrame.requestToggleAudio('user-id', true); // Request mute// Allow user to broadcast (moderator action)
sambaFrame.allowBroadcast('user-id');
sambaFrame.allowBroadcast({ userId: 'user-id', audio: true, video: false });
// Revoke broadcast permission
sambaFrame.disallowBroadcast('user-id');
// Screenshare permissions
sambaFrame.allowScreenshare('user-id');
sambaFrame.disallowScreenshare('user-id');// Raise own hand
sambaFrame.raiseHand();
// Lower hand (own or others if moderator)
sambaFrame.lowerHand();
sambaFrame.lowerHand('user-id');// Toolbar
sambaFrame.showToolbar();
sambaFrame.hideToolbar();
sambaFrame.toggleToolbar();
sambaFrame.changeToolbarPosition('left'); // 'left' | 'right' | 'bottom'
// Topbar
sambaFrame.showTopbar();
sambaFrame.hideTopbar();
sambaFrame.toggleTopbar();
// Layout
sambaFrame.changeLayoutMode('tiled'); // 'auto' | 'tiled'// Pin user's video
sambaFrame.pinUser('user-id');
sambaFrame.pinUser('user-id', 'screenshare'); // Pin specific tile type
sambaFrame.unpinUser();
// Maximize user's video
sambaFrame.maximizeUser('user-id');
sambaFrame.maximizeUser('user-id', 'screenshare');
sambaFrame.minimizeUser();
// Local tile
sambaFrame.minimizeLocalTile();
sambaFrame.maximizeLocalTile();
// Minimize pinned/maximized content
sambaFrame.minimizeContent();// Mute all audio output from iframe
sambaFrame.muteFrame();
sambaFrame.unmuteFrame();
sambaFrame.toggleMuteFrame();sambaFrame.showCaptions();
sambaFrame.hideCaptions();
sambaFrame.toggleCaptions();
sambaFrame.configureCaptions({
fontSize: 'large', // 'small' | 'medium' | 'large'
spokenLanguage: 'en-US',
applySpokenLanguageToAll: true // Apply spoken language to all participants (moderator only)
});// Enable blur
sambaFrame.enableVirtualBackground({ type: 'blur' });
// Enable image
sambaFrame.enableVirtualBackground({
type: 'image',
value: 'background-name' // From configured backgrounds
});
// Enable custom image URL
sambaFrame.enableVirtualBackground({
type: 'imageUrl',
value: 'https://example.com/background.jpg'
});
// Disable
sambaFrame.disableVirtualBackground();
// Configure (set options without enabling)
sambaFrame.configureVirtualBackground({ type: 'blur' });// Create new whiteboard
sambaFrame.createWhiteboard({ personal: false, folderId: 'folder-id' });
// Open/close whiteboard
sambaFrame.openWhiteboard('whiteboard-id');
sambaFrame.closeWhiteboard('whiteboard-id');
sambaFrame.toggleWhiteboard();
// Add image to whiteboard (URL - requires CORS on external server)
sambaFrame.addImageToWhiteboard({
url: 'https://example.com/diagram.png',
position: { x: 100, y: 50 } // Optional, auto-centers if omitted
});
// Add image via base64
sambaFrame.addImageToWhiteboard({
base64: 'data:image/png;base64,iVBORw0KGgo...'
});// Open file from library
sambaFrame.openLibraryFile('file-id');
sambaFrame.closeLibraryFile('file-id');
sambaFrame.toggleLibraryFile('file-id');// Leave session (current user)
sambaFrame.leaveSession();
// End session for everyone (requires permission)
sambaFrame.endSession();
sambaFrame.endSession(true); // Show confirmation dialog// Check if feature is enabled
if (sambaFrame.featureEnabled('recordings')) {
showRecordButton();
}Add custom actions to the 3-dots menu on video tiles.
// Add a custom action to remote user tiles
sambaFrame.addTileAction(
'sendEmail', // Action identifier
{ label: 'Send Email', scope: 'remote' }, // Properties
() => console.log('Send email clicked') // Callback
);
// Remove the action
sambaFrame.removeTileAction('sendEmail');Scope values:
'all'- All tiles'remote'- Other users' tiles'local'- Current user's tile'screenshare-local'- Local screen share'screenshare-remote'- Remote screen share
Add custom HTML panels to the video call UI.
// Add a custom tile (must be called after userJoined)
sambaFrame.addCustomTile({
name: 'poll-panel', // Tile identifier and title
html: '<div>Poll content</div>', // HTML content
position: 'last' // 'first' or 'last' in tile list
});
// Remove a custom tile
sambaFrame.removeCustomTile('poll-panel');
// Send data to the custom tile's iframe
sambaFrame.sendMessageToCustomTile({
name: 'poll-panel', // Must match addCustomTile name
event: 'updateResults', // Custom event name (optional)
origin: '*', // postMessage origin (optional)
data: { results: [1, 2, 3] } // Payload (optional)
});Receiving messages in the custom tile:
window.addEventListener('message', (event) => {
console.log(event.data); // { event: 'updateResults', data: { results: [1, 2, 3] } }
});Override UI interactions with custom logic. The default action is suppressed.
// Override leave session with confirmation
const leaveCallback = () => {
if (confirm('Are you sure you want to leave?')) {
sambaFrame.leaveSession();
}
};
sambaFrame.addUICallback('leaveSession', leaveCallback);
// Remove the override
sambaFrame.removeUICallback('leaveSession', leaveCallback);Supported events: 'leaveSession'
Listen to JavaScript events inside the iframe (e.g., for custom key combinations).
// Listen for keyup on window
const keyHandler = (payload) => console.log('keyup', payload);
sambaFrame.addFrameEventListener('keyup', 'window', keyHandler);
// Listen for clicks on document
const clickHandler = (payload) => console.log('click', payload);
sambaFrame.addFrameEventListener('click', 'document', clickHandler);
// Remove listener
sambaFrame.removeFrameEventListener('keyup', 'window', keyHandler);Targets: 'window' or 'document'
Change room appearance without reloading.
// Switch to dark theme
sambaFrame.changeBrandingOptions({ paletteMode: 'dark' });
// Custom colors
sambaFrame.changeBrandingOptions({
primaryColor: '#0066FF', // Accent color
toolbarColor: '#1a1a1a', // Toolbar background
roomBackgroundColor: '#000000' // Room background
});Options:
paletteMode-'dark'or'light'primaryColor- Hex color for accentstoolbarColor- Hex color for toolbarroomBackgroundColor- Hex color for background
import DigitalSambaEmbedded, {
InitOptions,
User,
RoomState,
FeatureSet,
PermissionTypes
} from '@digitalsamba/embedded-sdk';
const sambaFrame: DigitalSambaEmbedded = DigitalSambaEmbedded.createControl({
url: roomUrl,
root: container
});
sambaFrame.on('userJoined', (event: { data: User }) => {
console.log(event.data.name);
});Most methods have no effect before the user joins. Always wait:
sambaFrame.once('userJoined', () => {
// Now safe to call methods
sambaFrame.disableAudio();
});
sambaFrame.load();