Skip to content

Building widgets (Dima SDK)

Developer reference for building Overlay Studio custom widgets with a manifest, editable fields, and Dima SDK v1.

This reference is for developers building custom widgets for Overlay Studio. Each widget is a lightweight HTML, CSS, and JavaScript package that executes inside a sandboxed iframe. Native widgets talk directly to the Dima SDK, while StreamElements packages run on top of a compatibility layer built over the same SDK.

Looking for the streamer setup guide instead? See Custom widgets.

You can also code directly inside Overlay Studio using New widget and the Dima SDK starter—see Write code in Studio.

TypeScript definitions for the SDK ship inside Download for your editor.

A widget package can include the following files:

FilePurpose
widget.jsonOptional manifest for native Dima widgets; required to select the native Dima engine and declare live data categories. StreamElements packages without one are inferred from their code.
widget.iniStreamElements mapping from package sections to filenames.
html.txtHTML markup injected into the iframe body.
css.txtStylesheet injected into the iframe.
js.txtClassic JavaScript script executed after the HTML is in place.
fields.txtJSON object describing user-editable settings.
data.txtJSON object holding saved setting values.

StreamElements packages use widget.ini to locate the HTML, CSS, JavaScript, fields, and data files. Native Dima widgets use widget.json alongside the same content files and don’t need widget.ini. On import, Studio keeps the original fields and data text intact so exports stay lossless.

widget.json is a JSON object supporting these properties:

FieldRequiredMeaning
engineNo"dima" for native Dima SDK widgets, or "streamelements" to load the StreamElements compatibility layer. Defaults to "dima" whenever a manifest is present; packages without a manifest default to StreamElements.
apiNoDima SDK major version. Defaults to 1; unsupported versions are rejected.
usesNoArray of live data categories the widget needs: chat, alerts, storage, counters, session, signals, polls, goals, tts, triggers, rewards, pets, duels, roulette, dimafx, hypetrain, and/or ads. Defaults to an empty array. Unknown entries are reported and ignored.
nameNoDisplay name shown in Studio.
authorNoAuthor or creator name.
versionNoPackage version string.
descriptionNoBrief summary of what the widget does.
signalsNoOptional signal definitions (up to 30) used to generate ready-made commands in Studio. Each takes a lowercase name, optional description (up to 200 characters), and optional values examples (up to 30 entries, each up to 60 characters). Invalid entries are skipped with the import note signal declaration skipped.
{
"engine": "dima",
"api": 1,
"name": "Pastel chat",
"author": "Ana",
"version": "1.2.0",
"description": "Chat with pastel bubbles",
"uses": ["chat", "alerts", "storage", "counters", "session", "signals", "polls", "goals", "tts", "triggers", "rewards"],
"signals": [{ "name": "feed", "description": "Feed the pet", "values": ["pizza", "cake"] }]
}

Request only the data categories your widget genuinely uses:

  • chat enables chat messages, message deletions, and chat clears.
  • alerts enables follow, subscription, gift, Bits, raid, and tip alert categories (real tip events aren’t available yet).
  • storage enables persistent key/value storage, counters enables reading command counts, session enables recent events and totals, and signals lets chat commands trigger the widget.
  • polls, goals, hypetrain, and ads provide their respective live state snapshots.
  • tts, triggers, rewards, pets, duels, roulette, and dimafx emit those bot events.

Studio presents the uses list to the channel owner on import, and published widgets only receive categories they declared. Editor button tests always work regardless of uses.

fields.txt is a JSON object keyed by setting name. Each field definition accepts type, label, value (default), group, and type-specific options such as min, max, step, and options. Settings sharing a group appear together in a collapsible section, while ungrouped fields land under General. Hidden fields remain readable from your script. Studio’s search filters by field labels. Each overlay layer stores only its overrides; resetting a setting clears that override.

Supported field types:

  • text, textarea, number, and slider (optional min, max, step)
  • checkbox
  • colorpicker
  • dropdown (options maps option values to display labels)
  • googleFont
  • image-input, video-input, and sound-input (add multiple: true for a list of URLs)
  • button (fires an editor-only button event to your widget)
  • hidden (omitted from the editor UI)

For example:

{
"accent": { "type": "colorpicker", "label": "Accent", "value": "#7c3aed", "group": "Look" },
"limit": { "type": "number", "label": "Messages on screen", "value": 6, "min": 1, "max": 30, "group": "Chat" },
"hideCommands": { "type": "checkbox", "label": "Hide !commands", "value": true, "group": "Chat" }
}

Field values resolve in order: field default → package data.txt → per-layer override. You can inject values into HTML and CSS with {key} or {{key}} (for example, {{countLabel}}). Only known keys are replaced; arrays join with commas and null becomes an empty string. Native Dima widgets only run template substitution in HTML and CSS—read current values from Dima.fields in JavaScript. StreamElements widgets also run substitution in JavaScript for compatibility. On import, Studio guards closing </script and </style sequences inside substituted values.

Inside the widget iframe, the SDK is exposed globally as Dima.

const ctx = await Dima.ready();
// ctx: { widget, channel, fields, mode, muted, session, goalSource }
Dima.fields; // current settings
const unsubscribe = Dima.on('chat', message => { /* ... */ });
Dima.off('chat', handler); // or call the function returned by Dima.on
Dima.storage.get('key'); // Promise resolving to a JSON value or null
Dima.storage.set('key', { seen: true }); // Promise
Dima.counters.get('!deaths'); // Promise<number>
Dima.html(message); // escaped text plus safe Twitch emote images
Dima.escape(viewerText); // escaped string
Dima.log('loaded'); // appears in Studio's Widget log
await Dima.setField('accent', '#ff66aa'); // editor only

Native Dima widgets use Dima.storage.get/set, the storage event, and "storage" in widget.json uses, while StreamElements widgets keep SE_API.store and kvstore:update.

  • Dima.setField(key, value, reload = true) is strictly for editor-only helpers: it updates a field programmatically, validates it against the field schema, and rejects in live mode.
  • Dima.done() is a no-op in v1.
  • Storage namespaces are isolated per widget ID for native Dima widgets, whereas StreamElements widgets share the channel-wide se namespace (matching StreamElements’ shared kvstore). Storage update events carry DimaStorageUpdate { key, value, namespace }, and a widget only receives updates for its own namespace (its widget ID for native Dima, or se for StreamElements widgets).

Add "signals" to uses to listen for chat-command signals. You can also list up to 30 signal definitions in widget.json so Studio can scaffold ready-made commands: omitting values generates a command with no argument; single-word examples pass the viewer’s first word (&p1); any example containing spaces passes all text after the command (&t). Names must use lowercase letters, digits, and _ (up to 40 characters); invalid definitions are skipped with signal declaration skipped.

{
"uses": ["signals"],
"signals": [{ "name": "feed", "description": "Feed the pet", "values": ["pizza", "cake"] }]
}

Listen for all signals or subscribe to a specific signal name. Because signal values originate from viewer input, always render them with textContent or Dima.escape(), never innerHTML.

Dima.on('signal', signal => { /* handle every signal */ });
Dima.on('signal:feed', signal => {
document.querySelector('.pet-status').textContent = `Eating ${signal.value || 'snack'}`;
});

A DimaSignal payload includes:

  • id, name, value (text following the signal name, or ''), json (parsed only when value is a JSON number, boolean, array, or object; otherwise null), args (value split on spaces), and at (milliseconds).
  • user: { id, login, name } plus verified Twitch badge roles (broadcaster, moderator, vip, subscriber), or null if unknown.
  • source: { kind, name }, where kind is command, keyword, event, or studio.
  • target: the layer name for targeted signals, or null otherwise.

In StreamElements compatibility mode, the exact same payload arrives via onEventReceived with listener: 'dima:signal' (obj.detail.event.name, .value, .user, etc.), letting a single codebase work on both engines.

Attach listeners with Dima.on(type, handler), which returns an unsubscribe callback; you can also remove listeners with Dima.off(type, handler).

Eventdata shapeRequires uses
chatDimaChat (shape below)chat
chat.delete{ messageId: string, userId: string | null }chat
chat.clear{ userId: string | null }; null means the whole chatchat
alertDimaAlert (shape below)alerts
button{ field: string, value: unknown }Editor only; always available in preview
fieldsThe current settings objectEditor only
storageDimaStorageUpdate { key: string, value: unknown, namespace: string } after a storage writestorage
session{ data: Record<string, unknown>, recents: unknown[] }session
signal / signal:<name>DimaSignalsignals
stateDimaState ({ name, value })polls, goals, hypetrain, or ads, according to name
ttsDimaTtstts
triggerDimaTriggertriggers
rewardDimaRewardrewards
petDimaPetpets
duelDimaDuelduels
rouletteDimaRouletteroulette
dimafxDimaDimafxdimafx

Call Dima.state(name, handler) to subscribe to the latest known snapshot and future updates for polls, goals, hype trains, or ad breaks. Whenever an OBS source connects or reconnects, the current snapshot is delivered again. Your handler fires once a value becomes known and on every subsequent change—if no value is known yet, it stays silent (unknown is distinct from an empty poll or goals list). The returned function unsubscribes. To watch all state domains at once, use Dima.on('state', ({ name, value }) => …).

const stopPolls = Dima.state('polls', ({ poll, prediction }) => {
document.querySelector('#poll-title').textContent = poll?.title ?? 'No poll yet';
});
Dima.state('goals', goals => {
document.querySelector('#goal-count').textContent = String(goals.length);
});
// Later: stopPolls();
  • hypetrain (requires "hypetrain" in uses): returns a DimaHypeTrain or null. Represents the active train or one that just finished—an ended train remains visible until its cooldown expires (at most two hours), then flips to null. If DomDimaBot misses an end event, it queries Twitch and clears stale active state when Twitch reports no train. Fields: id, phase (active or ended), level, total (Twitch point units), progress and goal (points toward and needed for the next level; both null once ended), topContributions, allTimeHigh ({ level, total } or null), type (regular, golden_kappa, or treasure), shared, sharedParticipants (channels in a shared train), startedAt, expiresAt (when the train ends without new contributions; null once ended), endedAt, and cooldownEndsAt. Each DimaHypeContribution has user (id, login, name), type (bits, subscription, or other), and total (points); Twitch publishes top contributors publicly. All timestamps are in milliseconds.
  • ads (requires "ads" in uses): returns DimaAds, with active (null or DimaAdBreak containing startedAt, endsAt, duration in seconds, and automatic for schedule-triggered breaks) and schedule (DimaAdSchedule or null when unknown). DimaAdSchedule exposes nextAt (also null when no break is scheduled or the channel is offline), duration (seconds), lastAt, snoozes, snoozeRefreshAt, and prerollFreeUntil—any schedule field can be null when Twitch omits it. All timestamps are milliseconds and durations are seconds. Because Twitch has no schedule-change event, DomDimaBot polls the schedule roughly once a minute while an OBS source with an ads widget is connected. Who started an ad is never exposed. Streamers who logged in before the ad-schedule scope was added may need to sign in again before schedule stops returning null.
  • polls (requires "polls" in uses): returns DimaPolls ({ poll, prediction }), where each property is null or a DimaPoll. A DimaPoll includes kind (poll or prediction), id, title, phase (active, locked, completed, archived, terminated, resolved, or canceled), choices, startedAt, deadline, endedAt, winnerId, and revision. Each choice carries id, title, votes, users, and points, plus optional channelPointsVotes and color. Data contains aggregate totals only and never identifies voters. Live poll/prediction state arrives once Twitch events are enabled via the same Polls & predictions setup shown on the Overlay tab.
  • goals (requires "goals" in uses): returns an array of DimaGoal entries from the layer’s selected goal source. Each entry provides id, source ('dima' or 'twitch'), name, metric (follows, subs, subPoints, bits, cheerers, or currency), mode, target, current, percent, currency (code or null), twitchType (e.g., follow, subscription_count, new_bit; null for Goals page goals), achieved (whether Twitch marked an ended Twitch goal as reached), status (scheduled, active, reached, or ended), startsAt, endsAt, windowSeconds, and period. Twitch goals set mode: 'twitch'; monetary amounts use currency units (for example, 87.5). Updates arrive within seconds of edits or progress changes and at least once per minute for time-based transitions. Goal state is read-only and never runs goal completion actions.

StreamElements-compatible widgets receive live state via onEventReceived: dima:hypetrain provides event.hypetrain (null when no train is visible), and dima:ads provides event.active and event.schedule.

Most bot events are live-only—an OBS source reconnecting after a drop won’t receive events missed while offline. Roulette results are the exception: they’re backed by saved spins and can replay for up to two minutes after endsAt. Every bot event includes at (milliseconds) and test (true for Studio tests).

EventDataNotes
tts (uses: ["tts"])DimaTts: id, phase (start or end), text, user, reasontext is the filtered spoken string. start fires when audio begins; end fires once when playback finishes with reason set to ended, skipped, cleared, or interrupted. Both phases share id; messages that never play produce no event.
trigger (uses: ["triggers"])DimaTrigger: id, triggerId, name, mediaType (audio, video, image, or unknown)Fires when a command, channel-point redemption, or Bits rule sends a trigger alert. Does not include a media URL, and a custom-widget-only overlay observes the event without playing the media.
reward (uses: ["rewards"])DimaReward: id, reward: { id, title, cost }, user, inputFires for every channel-point redemption, even rewards with no bot action. Treat input as viewer text—always use textContent or Dima.escape(), never innerHTML.
pet (uses: ["pets"])DimaPet: id, kind, phase, text, mood, resultFires when the pet starts speaking and once when it finishes, only for spoken replies. Handle done even if no speaking arrived first. text is the pet’s line, never the viewer’s prompt. Private DomDimaBot desktop app replies are not sent to widgets.
duel (uses: ["duels"])DimaDuel: id, phase, challenger, opponent, mode, winner, loser, endsAtNames are Twitch logins. started fires when a challenge is accepted or someone challenges the streamer; ended fires once after the fight, revealing the outcome only then.
roulette (uses: ["roulette"])DimaRoulette: id, rouletteId, name, phase, label, endsAtFires spinning, then result with the winning label when the spin finishes. Backed by saved spins so API restarts or OBS reconnects don’t lose results; sources connecting within two minutes after endsAt still receive it (check endsAt if you want to skip old spins).
dimafx (uses: ["dimafx"])DimaDimafx: id, item, source, bits, credits, user, messageFires once when a DimaFX item starts playing (requires the DimaFX overlay to be connected). Viewer identity is present only when shared with the extension. Custom TTS message is viewer input—use textContent or Dima.escape(), never innerHTML.

Field details for the four feature events:

  • DimaPet: DimaPet.kind is talk, ask, or tts; phase moves from speaking to done; mood is null when moods are off; result is completed or stopped on done only.
  • DimaDuel: DimaDuel.phase moves from started to ended; challenger and opponent are Twitch logins; mode is overlay or chat; winner and loser stay null until ended; endsAt may be null.
  • DimaRoulette: DimaRoulette.phase moves from spinning to result; label is populated on result only.
  • DimaDimafx: item is { id, name, type }; source is bits, credits, saved, or test; bits and credits hold the paid amount or null; user is { id, login, name } only when the viewer shared their identity with the extension (otherwise null); message holds viewer text only for custom TTS items (otherwise null).
Dima.on('tts', event => {
if (event.phase === 'start') document.querySelector('#spoken').textContent = event.text;
});
Dima.on('trigger', event => console.log(event.name, event.mediaType));
Dima.on('reward', event => {
document.querySelector('#reward-input').textContent = event.input ?? '';
});
Dima.on('pet', event => {
if (event.phase === 'speaking') document.querySelector('#pet').textContent = event.text;
});
Dima.on('duel', event => console.log(event.phase, event.challenger, event.opponent));
Dima.on('roulette', event => {
if (event.phase === 'result') document.querySelector('#winner').textContent = event.label ?? '';
});
Dima.on('dimafx', event => console.log(event.item.name, event.source));

Full type definitions live under DimaPet, DimaDuel, DimaRoulette, and DimaDimafx. StreamElements-compatible widgets receive these same events through onEventReceived using listeners dima:pet, dima:duel, dima:roulette, and dima:dimafx (obj.detail.event). All four include at (milliseconds) and test (true for Studio tests). Pet, duel, and DimaFX events are live-only, whereas roulette results come from saved spins and can replay for up to two minutes after endsAt.

Whenever any widget in an overlay declares one of these categories, Studio enables the Bot events row so you can send TTS (start, followed by end three seconds later), Trigger, Channel points, Sample poll, Sample goals, Sample hype train, Sample ad break, Pet reply, Duel, Roulette, and DimaFX purchase events to either the preview or OBS. Paired events automatically send their second phase about three seconds later, and the code editor preview exposes the same test buttons. Sample state sent to OBS stays visible for about a minute before real state returns; Studio previews initialize with your channel’s real polls, goals, hype train, and ad state.

The Replay recent chat button inside the Chat row works in the preview only. It replays the channel’s last 20 stored messages from oldest to newest as plain text (no emotes, name colors, or badge images) and may include messages deleted by moderators, so it is never sent to OBS.

Dima.ready() resolves to an object containing widget: { id, layerId, name, revision }, channel: { id, login, name }, fields, mode ("editor" or "live"), muted, session (or null), and goalSource ('dima' or 'twitch'), reflecting the layer’s selected goal source.

A chat event (DimaChat) has this shape:

{
id: string; platform: 'twitch'; at: number;
user: {
id: string; login: string; name: string; color: string | null;
badges: Array<{ set: string; version: string; info: string; title: string;
images: { '1x': string; '2x': string; '4x': string } }>;
roles: { broadcaster: boolean; moderator: boolean; vip: boolean; subscriber: boolean;
founder: boolean; artist: boolean; staff: boolean; partner: boolean; turbo: boolean; prime: boolean };
subMonths: number | null;
};
text: string;
parts: Array<
| { type: 'text'; text: string }
| { type: 'emote'; text: string; id: string; animated: boolean; images: { '1x': string; '2x': string; '4x': string } }
| { type: 'cheer'; text: string; prefix: string; bits: number; tier: number }
| { type: 'mention'; text: string; user: { id: string; login: string; name: string } }
>;
kind: 'text' | 'highlighted' | 'intro' | 'power-up' | 'gigantified';
action: boolean; firstMessage: boolean; bits: number; rewardId: string | null;
reply: { id: string; user: { id: string; login: string; name: string }; text: string } | null;
sharedChat: { channelId: string; messageId: string } | null;
}

An alert event (DimaAlert) has this shape:

{
id: string; type: 'follow' | 'sub' | 'resub' | 'gift' | 'bits' | 'raid' | 'tip';
at: number; test: boolean; user: { id: string; login: string; name: string } | null;
amount: number; // months, gifts, Bits, raid viewers, or tip amount
tier: '1000' | '2000' | '3000' | 'prime' | null;
months: number | null; streak: number | null; message: string | null;
recipient: { id: string; login: string; name: string } | null;
currency: string | null; rule: { id: string; name: string } | null;
}

DimaSession.data mirrors StreamElements’ session snapshot (keys like follower-latest, subscriber-recent, cheer-session, and follower-week), while recents holds recent alert entries:

  • *-session covers the current stream (or the past 24 hours if no stream start is recorded), *-week covers the past 7 days, and *-month (followers, subscribers, Bits, and raids) covers the current UTC calendar month.
  • *-latest and *-recent are derived from the newest 500 alerts, with up to 25 entries per *-recent array.
  • follower-total and subscriber-total mirror your dashboard totals (follows update live). cheer-total and raid-total cover the last 90 days (the channel event retention window), so they can drop as older events age out. Subscriber counts include each subscriber once plus gifted subs—a 5-sub community gift adds 5.

The StreamElements manual goal keys (follower-goal, subscriber-goal, cheer-goal, and tip-goal) each return { amount } based on the layer’s Goal data setting:

  • For Goals page goals, each key pulls from the first active matching goal in the streamer’s list, or the first reached goal if none are active. The amount is current progress—not the target—calculated with the counting rule chosen on the Goals page (since creation, current count, set dates, rolling window, or calendar month). Money (tip-goal) uses currency units (e.g., 12.34) and includes everything counted by that goal (Bits, subs, custom items—not just tips).
  • For Twitch goals, follower goals feed follower-goal, sub goals feed subscriber-goal (counts before points), Bits goals feed cheer-goal, and tip-goal stays 0 because Twitch has no money goals. Any unmatched key returns 0.
  • Updated values flow through session (Dima) and onSessionUpdate (StreamElements), reaching OBS widgets within seconds of changes. Studio test alerts update session totals in the preview and push updated totals to OBS without touching real data; Twitch-sourced goals don’t change on test alerts because Twitch computes its own goals, though session counts still update. Tip event keys (tip-*) stay at 0 until DomDimaBot tipping launches.

Totals that cannot yet be computed default to zero. Inline HTML onerror="…" handlers in StreamElements widgets can safely reference functions defined in the widget’s script—early image errors wait until that script runs, matching StreamElements behavior.

Use Dima.html(message) to escape message text and render safe <img> elements for Twitch emotes. When building HTML strings with viewer-controlled text, escape values via Dima.escape, or prefer textContent for plain text nodes.

Here is a compact chat widget adapted from the dima-chat sample. It declares its data needs, escapes viewer text safely, handles moderation events, and uses both storage and command counters.

widget.json:

{
"engine": "dima", "api": 1, "name": "Dima sample chat", "author": "DomDimaBot",
"version": "1.0.0", "description": "A compact chat overlay", "uses": ["chat", "storage", "counters"]
}

fields.txt:

{
"accent": { "type": "colorpicker", "label": "Accent", "value": "#7c3aed", "group": "Look" },
"limit": { "type": "number", "label": "Messages on screen", "value": 6, "min": 1, "max": 30, "group": "Chat" }
}

html.txt:

<ol class="chat" aria-live="polite"></ol>
<footer><span class="count">0</span> alerts · <span class="deaths">0</span> deaths</footer>

css.txt:

:root { --accent: {accent}; }
body { margin: 0; color: white; font: 18px system-ui, sans-serif; }
.chat { display: flex; flex-direction: column; gap: 6px; list-style: none; padding: 12px; }
.msg { padding: 8px 12px; border-left: 4px solid var(--accent); background: #111c; }
.msg img.dima-emote { height: 1.4em; vertical-align: middle; }

js.txt:

const chat = document.querySelector('.chat');
const count = document.querySelector('.count');
const deaths = document.querySelector('.deaths');
let fields = {};
Dima.ready().then(async ctx => {
fields = ctx.fields;
count.textContent = String((await Dima.storage.get('alerts')) ?? 0);
deaths.textContent = String(await Dima.counters.get('!deaths'));
});
Dima.on('fields', next => { fields = next; });
Dima.on('chat', message => {
const item = document.createElement('li');
item.className = 'msg';
item.dataset.id = message.id;
item.innerHTML = '<strong>' + Dima.escape(message.user.name) + '</strong> ' + Dima.html(message);
chat.append(item);
while (chat.children.length > Number(fields.limit || 6)) chat.firstElementChild.remove();
});
Dima.on('chat.delete', ({ messageId }) => {
chat.querySelector('[data-id="' + CSS.escape(messageId) + '"]')?.remove();
});
Dima.on('chat.clear', () => { chat.replaceChildren(); });

Notice there is no widget.ini: Studio imports these native files straight into an overlay.

Setting "engine": "streamelements" (or importing a package without widget.json) enables the compatibility layer, which bridges Dima SDK events to standard StreamElements browser events:

  • onWidgetLoad fires right after Dima.ready() with detail.channel, currency, fieldData, recents, session, overlay, and emotes.
  • onEventReceived maps chat to listener: "message", single-message deletion to "delete-message", user chat clear to "delete-messages", and alerts to "follower-latest", "subscriber-latest", "cheer-latest", "raid-latest", or "tip-latest". It also delivers "widget-button", "kvstore:update", "dima:signal", "dima:polls" (event.poll, event.prediction), "dima:goals" (event.goals), "dima:tts", "dima:trigger", and "dima:reward".
  • onSessionUpdate fires on session changes with { session }.

For chat messages, event.data supplies time, IRC-style tags, nick, userId, displayName, displayColor, badges, channel, text, isAction, emotes, and msgId, while event.renderedText provides escaped HTML with Twitch emotes. Alert payloads include the standard fields for each type—such as name, amount, tier, message, gifted, sender, or currency.

Available SE_API methods: store.get/set, counters.get(name), sanitize({ message }), cheerFilter(text), getOverlayStatus(), resumeQueue(), and setField(key, value, reload). sanitize returns the message unchanged, and setField works only in the editor. Key compatibility behaviors:

  • Storage scope: Unlike native Dima widgets (which are scoped per widget), SE_API.store stays channel-wide.
  • Alert queueing: Defining a widgetDuration setting queues onEventReceived alert events one at a time, holding each for that many seconds (up to 300) unless SE_API.resumeQueue() advances early. Up to 50 alerts can wait; chat and other events never queue. Without widgetDuration, alerts aren’t queued.
  • Whole-chat clear: StreamElements has no native whole-chat-clear event, so clearing the entire chat reloads StreamElements widgets fresh, whereas clearing a single user maps to delete-messages (native Dima widgets get chat.clear with userId: null).
  • Unsupported features: No StreamElements API token, StreamElements-only APIs, or third-party emotes.
  • Substitution & reload: StreamElements widgets run {key} / {{key}} substitution across HTML, CSS, and JavaScript, and reload when editor settings change—matching native StreamElements behavior. Native Dima widgets substitute only in HTML and CSS, read JavaScript settings via Dima.fields, and receive live fields events in the editor.
LimitMaximum
HTML or CSS file512 KB each
JavaScript file1 MB
Fields file256 KB
Data file128 KB
widget.json manifest16 KB
Whole package2 MB
Settings per widget500
Changed settings per layer64 KB
Store value64 KB of JSON
Store keys per channel500 keys and 2 MB total
Store key name100 characters
RPC request payload64 KB
Calls from one frame30 RPCs per second
Log messages from one frame200 per minute

Each widget frame emits a heartbeat every two seconds. If a frame stops responding for ten seconds, Studio reloads it up to three times within five minutes before disabling the widget with an error. RPC calls or log lines past their rate limits are dropped. Because the sandbox shares a process with the host page, a tight infinite loop can still stall rendering—keep work lightweight, avoid blocking loops, and use timers for recurring updates.

Widgets run in a sandboxed iframe with scripts enabled and an opaque origin. They cannot access site storage or logins, inspect the parent page, other layers, or the private overlay URL, open popups, dialogs, downloads, or forms, or navigate the page. Only the channel owner can import or edit widget code. The widget talks to DomDimaBot through the rate-limited SDK—it can read or write its own saved values and read command counters. As a best effort, the SDK strips OBS’s window.obsstudio API before widget code runs; because inner frames or navigated pages receive a fresh copy, OBS browser source Page permissions still matter—recommend No access to OBS for sources displaying imported widgets.

By default, widget code can load files and scripts from any website, forward public channel data (chat messages, alerts, usernames) to remote servers (exposing the streaming PC’s IP address), render anything on stream, and consume CPU and memory. Remote scripts or styles run as part of the widget and can change after import. When Studio detects outside scripts or styles, the import dialog displays This widget loads code from other sites, lists the detected hosts, warns that external code can change and send received data elsewhere, and offers the owner-controlled Block outside connections for this widget checkbox (off by default). Layer settings also show Loads code from …. The owner can change Block outside connections anytime in layer settings; widget.json cannot set or override this choice.

When outside connections are blocked, the iframe enforces a Content-Security-Policy of default-src 'none' (allowing inline scripts and eval), connect-src 'none', frame-src 'none', and worker-src 'none':

  • Only inline code runs—no scripts from external origins, including StreamElements. Styles may additionally load from Google Fonts.
  • Images, fonts, audio, and video load only from DomDimaBot, copied assets, cdn.streamelements.com, static.streamelements.com, Google Fonts, and static-cdn.jtvnw.net (Twitch emotes and badges).
  • Fetches, sockets, WebRTC, inner frames, and workers are blocked, DNS prefetching is disabled, and the policy is also set on the iframe’s csp attribute—any navigation or reload attempt (even before initial load) is stopped.
  • The widget’s own inline code and settings keep working. Bundle libraries inline or use copied files; widgets relying on external CDNs like cdnjs or jsDelivr or external fonts may fail to load.
  • Studio’s preview enforces the exact same rule, and connected OBS sources reload immediately whenever the owner toggles it.
  • This blocks typical tracking, uploads, and remote code changes, but is not airtight against a determined author: the HTTP request for a blocked navigation fires before the frame is stopped, and explicit DNS hints can still resolve.

Finally, the SDK provides an in-memory shim for localStorage and sessionStorage—do not expect values stored there to persist across reloads. Widgets only receive the live categories declared in uses. Always escape viewer-supplied text before injecting it into HTML, or use textContent for plain text.

Docs assistant

Ask in your own words. Answers come from these docs, with links to the right page.

Try asking

Current page: Building widgets (Dima SDK)

AI can make mistakes. Check the linked page.