Appearance
SDK API Reference
The complete API for building Dissent plugins.
Loading the SDK
Script tag (no toolchain)
html
<script src="https://app.dissent.chat/sdk/v1/dissent-plugin-sdk.iife.js"></script>
<script>
Dissent.init().then(ctx => {
// Your plugin code here
});
</script>ES module
The same SDK is served as an ES module, with Dissent as its default export:
html
<script type="module">
import Dissent from 'https://app.dissent.chat/sdk/v1/dissent-plugin-sdk.js';
const ctx = await Dissent.init();
</script>Both builds come from one source and expose the identical API; the module build also sets window.Dissent.
There is no npm package
@dissent/plugin-sdk is not published, and no type definitions are shipped. The types below are copied from the SDK source; paste the ones you need into your project.
Dissent.plugin({…}) — describe the parts, the SDK wires them
js
const tally = Dissent.plugin({
settings: { greeting: { label: 'Greeting', default: 'Hello' } }, // admin settings (config_schema)
views: { // one per place, or `default`
channel: (ctx) => `<h2>${ctx.settings.greeting}, ${ctx.channel.name}</h2>`,
sidebar: (ctx, root) => { root.textContent = 'Side panel'; }, // or draw into root yourself
},
commands: { tally: { description: 'Add one', run: (cmd, ctx) => 'Added' } }, // Dissent.onCommand
buttons: { yes: (click, ctx) => 'Thanks!' }, // Dissent.onInteraction, by component id
forms: { signup: (form, ctx) => 'Got it' }, // …by form id
messageActions: { Echo: { description: 'Echo', run: (m) => m.message.content } },
});
await tally.ready; // the host said hello and the view is drawn
await tally.render(); // draw again after your data changedPlaces: channel, sidebar, profile, embed, personal, games, overlay, phone (falls back to sidebar), default. events and webhooks belong to the server half's plugin({…}) (server SDK) and are listed here only so tools can generate the manifest. It is the same API as the methods below — nothing new is reachable through it — and it is the shape the plugin kit's recipes use. Your first plugin in 10 minutes walks through it with the plugin kit; Every SDK call lists every call and the permission it needs.
Methods
Dissent.init(options?: DissentInitOptions): Promise<PluginContext>
Initialize the plugin and retrieve the context.
Parameters:
| Name | Type | Description |
|---|---|---|
options.onFallback | () => void | Callback if running outside Dissent. Useful for development. |
Returns: PluginContext object with all context data.
Example:
javascript
const ctx = await Dissent.init({
onFallback: () => console.log('Not in Dissent'),
});Dissent.getContext(): PluginContext | null
Synchronously get the context, or null if init() has not resolved yet.
Plugins cannot read channel messages
There is no getMessages(), and no permission that grants message history. channel:read was removed on 2026-08-15: together with fetch:external it was the whole path by which a plugin could send a user's conversations elsewhere. The host does not forward chat messages to plugins as events either.
Dissent.getUser(): Promise<PluginUser | null>
Get the viewing user's display name. Requires profile:read; without it the call rejects with profile:read not granted.
Returns: { displayName, avatarUrl }. avatarUrl is currently always null. For a profile-context plugin, the profile owner is already in ctx.user.
Example:
javascript
if (ctx.permissions.includes('profile:read')) {
const user = await Dissent.getUser();
console.log(`Hello, ${user.displayName}!`);
}Dissent.fetch(url)
Make an HTTP request through the Dissent proxy. All external requests must use this.
Requires: fetch:external permission
Signature:
typescript
Dissent.fetch(url: string, options?: {
method?: 'GET' | 'POST'; // default 'GET'
body?: string; // request body
headers?: Record<string, string>; // request headers
}): Promise<{ status: number; body: string; content_type: string }>Parameters:
| Name | Type | Description |
|---|---|---|
url | string | Full URL (http/https only) |
options.method | 'GET' | 'POST' | HTTP method (default 'GET') |
options.body | string | Request body (for POST) |
options.headers | Record<string, string> | Extra headers. Identity and transport headers (Cookie, Host, Origin, Referer, User-Agent, Sec-*, Proxy-*, X-Forwarded-*, …) are dropped. |
Returns: Promise<{ status: number; body: string; content_type: string }> — the proxied response with status code, raw body string, and content type.
Notes:
- The host must be listed in the manifest's
allowed_fetch_domains(exact match, every redirect too); anything else is refused. - The response body is cut off at 1 MB.
- Your IP is never exposed; the request comes from dissent-core.
Example:
javascript
const res = await Dissent.fetch('https://api.example.com/data');
const data = JSON.parse(res.body);Dissent.postMessage(content: string, options?: { components }): Promise<void>
Post a message to the current channel as the plugin bot. Requires bot:post, and a channel: in a frame with no channel it rejects with no channel context.
Parameters:
| Name | Type | Description |
|---|---|---|
content | string | Message content (plain text or markdown) |
options.components | PluginComponent[] or rows | Buttons, link buttons and dropdowns under the post, drawn by Dissent — see Buttons, dropdowns and forms. The node checks them; a post it refuses rejects with the reason |
Example:
javascript
await Dissent.postMessage('The event has started!');Dissent.on(event: string, callback: (data: unknown) => void): void
Listen for events from the host app. The handler receives the event's data.
Events the host actually sends:
| Event | Data | When it fires |
|---|---|---|
theme:change | { [cssVar: string]: string } | The user switches themes |
| any name | whatever the sender put in data | A realtime event under that name was published to this plugin's install in the current channel (for example by the same plugin open on another member's screen). Only delivered to frames granted realtime. The SDK has no publish method; send the realtime:publish action — see postMessage Protocol. |
game.saves.changed | { game } | See Personal plugins — use Dissent.gameSaves.onChange |
No message or member events
message:new, message:deleted, member:join and member:leave appear in an old SDK comment, but nothing in the host emits them. A handler for them never runs.
Example:
javascript
Dissent.on('theme:change', (theme) => {
Object.entries(theme).forEach(([key, value]) => {
document.documentElement.style.setProperty(key, value);
});
});Dissent.onCommand(command: string, handler: (cmd: CommandInvocation) => CommandAnswer | Promise<CommandAnswer>): void
Run one of your commands when a member types it. Commands are declared in your manifest ("manifest_version": 2, see the manifest); Dissent suggests them in the chat box with your plugin's name and where it came from, and the member's node reads the options from what they typed.
- Your plugin has a server half → the node runs the command there (trigger
"command", read it withcommand()from the server SDK) and this handler is not called. - No server half → Dissent opens your panel and calls this handler with the same payload.
What the member typed never goes into the channel. Return text for your reply — shown the way your manifest's reply says ("private": only they see it; "public": posted as your plugin, needs bot:post) — or { content, visibility, components } to choose (buttons work on a private reply too), { form } to open a form, or nothing. The node checks and carries out your answer exactly as it does a server half's.
CommandInvocation:
| Field | Type | Description |
|---|---|---|
command | string | The name, without / |
options | object | The options, already read by type (integer → number, boolean → true/false, user / channel → { id, name }) |
args | string | Everything typed after the command |
channel_id | string | Where it was typed |
user | { id, name } | null | From the member's Dissent node. null for someone who chose "View without joining" |
viewer | boolean | true for that member |
Example:
javascript
// manifest.json: "commands": [{ "name": "roll", "description": "Roll a die",
// "options": [{ "name": "sides", "type": "integer", "required": true }] }]
Dissent.onCommand('roll', (cmd) => {
const n = cmd.options.sides;
return `🎲 ${1 + Math.floor(Math.random() * n)} (d${n})`;
});Limits: 10 commands a minute per member per plugin (the server admin can lower it); an admin can turn any command off for their server.
Dissent.onInteraction(handler: (ix: InteractionInvocation) => string | void | Promise<string | void>): void
Handle clicks on your posts' buttons and dropdowns when your plugin has no server half — Dissent opens your panel and calls this with the node's payload (kind, component_id, values, message, channel_id, user, viewer; same fields as the server half's interaction()). Return text to answer only the person who clicked, or { content, visibility, components, update, form } — update changes the clicked post (your own) — see Buttons, dropdowns and forms.
javascript
Dissent.onInteraction((ix) => ix.component_id === 'yes' ? 'Thanks for voting!' : undefined);Dissent.onMessageAction(action: string, handler: (m: MessageActionInvocation) => CommandAnswer | Promise<CommandAnswer>): void
Receive a message a member chose to send you — right-click (long-press on a phone) → Send to plugin → <your plugin> · <action> — when your plugin has no server half. Declare the action in your manifest's message_actions. m.message is that one message (content, author, created_at, attachment names, encrypted); m.user is who sent it. Return text (only they see it) or { content, visibility: 'public' } (needs bot:post). '*' receives every action. With a server half the node runs it there (trigger message_action, messageAction() in the server SDK) — see Send to plugin and giving roles.
javascript
Dissent.onMessageAction('Translate', (m) => translate(m.message.content));Other methods and namespaces
| Member | Requires | What it does |
|---|---|---|
imageUrl(remoteUrl) | — | Returns a node-proxied URL for a remote http(s) image, so it loads under the frame's CSP without exposing the user's IP. Relative URLs are returned unchanged. Synchronous. |
mediaUrl(url) | — | Adds stream=1 to a node attachment URL (/api/v1/storage/view/…) so <video>/<audio> stream through the node instead of redirecting. Other URLs are returned unchanged. Synchronous. |
media.embed(url, title?) | media:embed | Opens an embedded media overlay (streams, videos). |
voice.setGain(userId, gain) | voice | Sets the local playback volume of a voice participant, for this user only. |
gallery.contributors(), list(userId, folder), myFolders(), share(folder, gameName), unshare(folder, userId?), editClip(attachmentId, patch, folder), deleteClip(attachmentId), rate(attachmentId, value), featured(window?) | clips:gallery | The current channel's clip gallery. rate takes 1–5; featured takes 'week' or 'all' (default). |
gameTelemetry.status(game), bind(game, channelId?), unbind(game) | game:telemetry | Live match data from a game on the user's machine. Broadcasting is desktop-only; status() reports desktop: false elsewhere instead of throwing. |
storageLocal.get(key), set(key, value), delete(key) | storage:local | Key–value storage on this device only. |
net.fetch(url, { method?, body?, headers? }) | net:direct | HTTPS from the user's computer to approved hosts. Resolves { status, body, content_type, etag, truncated }; desktop only. See Permissions. |
friends.list(), links(), invite(handle, payload), respond(id, accept), remove(id), match(game, run?), setAuto(enabled), onLinksChange(handler) | friends:link | This plugin on Dissent friends' accounts: invite and accept, or link automatically with friends in the same game (match, desktop, needs game:saves). Personal installs. See Permissions. |
wallet.connect({ chainId }), balance({ tokenContract, decimals }), signTypedData({ domain, types, primaryType, message, summary }) | wallet | ⚠ Host-mediated wallet access; signing shows a confirm dialog. |
storage, gameSaves and overlay are documented under Personal plugins below; storage works for server plugins too.
Dissent.game · no permission
For game plugins. Only works in a game frame opened at a table. lobbies() also works from the same plugin's sidebar.
| Method | What it does |
|---|---|
lobby() | The table: id, title, status, host_id, members, settings, you (your seat or null), and for rounds: seed, round, started_at, elapsed_ms, result. |
onLobby(fn) | The table changed. Read it again with lobby(). { closed: true, reason } when it closed. Returns an unsubscribe function. |
send(data) | Send to everyone else at the table. 1 KB of JSON at most, 20 a second. Watchers can't send. |
onMessage((from, data) => …) | Another player's message. Never your own. Returns an unsubscribe function. |
onRateLimited(fn) | Your messages are being dropped for going over 20 a second. |
setSettings(obj) | Host only, before Start. 4 KB of JSON at most. Values must be ones the manifest declared. |
finish(summary?) | Host only, after Start. Ends the game. summary is plain text shown in the room. |
lobbies() | This game's open tables on this server. Returns { lobbies }. |
report({ round, places }) | Once per round, for a game with rounds. Each place is { user_id, place, score?, label? }. |
start() | Play again. Host only, on an open table. |
leave() | Give up your seat and go back to the games room. |
sound() | { volume, deafened }: the app's volume (0 to 1) and whether the user is deafened. |
onSound(fn) | The volume or deafen changed. Returns an unsubscribe function. |
leaderboard({ board?, period? }) | This game's board. period is 'all' or 'week'. Returns { board, period, boards, wins, best }. Rejects with leaderboards_off. |
With the plain script (plugin-sdk.js), the same calls are gameLobby, onGameLobby, gameSend, onGameMessage, onGameRateLimited, gameSetSettings, gameFinish, gameLobbies, gameReport, gameStart, gameLeave, gameSound, onGameSound and gameLeaderboard.
Personal plugins
These namespaces serve personal plugins. Each requires the permission named.
Dissent.storage · storage:user / storage:server
| Method | Returns |
|---|---|
get(key, scope?) | the stored value, or null; rejects if the read is refused (e.g. too many reads) |
getMany(keys, scope?) | { key: value | null } for up to 32 keys, in one read (larger values take more than one request, done for you); rejects like get |
set(key, value, { scope?, ttl? }?) | resolves when saved; rejects if the node refuses (e.g. over 64 KB) |
delete(key, scope?) | resolves when deleted |
list(prefix?, scope?) | string[] of keys |
onChange(handler) | — calls handler({ scope, key }) when stored data changes (below) |
scope defaults to 'user' for a personal plugin — the only scope it may use — and 'server' otherwise.
Reacting to changes instead of polling
storage.onChange(handler) calls handler({ scope, key }) whenever this plugin's stored data changes — written by anyone, in a scope you are granted. friends.onLinksChange(handler) calls handler() when this install's links change. Neither carries data — by design: the event reaches every online member of the server, and only a read checks that this member allowed the plugin to read. Re-read only the key that changed. Reads are limited (120 a minute per member, shared by every plugin they have open): load a page, or catch up, with one getMany rather than a get per key, and treat a refused read as "try again later", never as "nothing stored".
For something that changes several times a second, have your server half send it to open pages with realtime.publish(event, data) (see Channel plugins) — pages hear it with Dissent.realtime.on(event, fn), no read at all — and keep storage for what a page opening later needs.
javascript
// Before: every member read the board every 10 seconds.
setInterval(async () => render(await Dissent.storage.get('board', 'server')), 10_000);
// After: read once, then again only when it changes — plus a slow safety poll, because a
// member of another node may miss an announcement.
const refresh = async () => render(await Dissent.storage.get('board', 'server'));
Dissent.storage.onChange(({ key }) => { if (key === 'board') refresh(); });
setInterval(refresh, 60_000);
refresh();Using the ES-module shim (plugin-sdk.js) instead of the built SDK: onStorageChange(fn) and onLinksChange(fn), called before your onEvent handler.
Dissent.gameSaves · game:saves
| Method | Returns |
|---|---|
currentRun(game) | the run in progress |
runs(game, { limit?, before? }?) | finished runs, newest first |
run(game, id) | one finished run |
profileStats(game) | whole-profile stats |
onChange(handler) | an unsubscribe function; handler({ game }) runs when a save is rewritten (in-app pages only) |
Every answer has a status and never throws for a missing save. Shapes and statuses: Game Saves.
Dissent.overlay · overlay:context
| Method | Returns |
|---|---|
context() | { game, surface, width, height, panelOpen }, or null outside the overlay |
onChange(handler) | an unsubscribe function; handler(context) runs with a fresh context whenever the game or the panel layer changes |
See Overlay Panels.
Context fields for personal plugins
ctx.contextType is 'personal'; ctx.placement is 'page' or 'overlay'; in the overlay, ctx.surface is the manifest surface id and ctx.game the game's catalog id.
Personal plugins are also told ctx.permissions (granted and still declared — read from the init context, since a personal plugin has no user), ctx.capabilities (the actions that will be allowed) and ctx.overlayApi (the overlay contract the host implements). All three are absent on hosts that predate them — treat absent as unknown, not as empty.
Types
Copied from the SDK source (src/lib/plugin-sdk/types.ts).
PluginContext
The object Dissent.init() resolves with.
typescript
interface PluginContext {
server: { id: string; name: string };
/** Present for channel, sidebar, and embed contexts. Absent for profile. */
channel?: { id: string; name: string };
/** The viewing user (the profile owner in profile context). null unless profile:read or identity was granted. */
user: PluginUser | null;
/** Admin-configured values. Decrypted at runtime by the host. */
config: Record<string, unknown>;
/** CSS custom properties from the Dissent theme. */
theme: Record<string, string>;
/** Permissions granted by this user. A personal plugin (which has no `user`) gets them from the init context. */
permissions: string[];
/** 'channel' | 'sidebar' | 'profile' | 'embed' | 'personal' */
contextType?: string;
/** Personal plugins only — the full page, or the compact overlay view. */
placement?: 'page' | 'overlay';
/** Overlay only — the manifest `overlay.surfaces[].id` this frame is. */
surface?: string;
/** Overlay only — the catalog id of the game running (e.g. `slay-the-spire-2`). */
game?: string;
/** Personal plugins — the actions this install can dispatch right now (granted ∩ declared, on its lane). */
capabilities?: string[];
/** Personal plugins — the overlay contract version the host implements. */
overlayApi?: number;
}There is no plugin metadata object and no embed field: the plugin's id, version and tier are not in the context.
PluginUser
typescript
interface PluginUser {
/** Stable user UUID. Only present when the plugin was granted 'identity'. */
id?: string;
displayName: string;
avatarUrl: string | null;
permissions: string[];
}PluginMessage and PluginMember
Both types are exported by the SDK, but no SDK method returns either one — there is no message access, and no SDK wrapper for the member list. They are listed for completeness.
typescript
interface PluginMessage {
id: string;
content: string;
user_id: string;
username: string;
created_at: string;
}
interface PluginMember {
user_id: string;
username: string;
display_name: string | null;
avatar_url: string | null;
}EmbedPayload
The payload of a broadcast embed (embed:render).
typescript
interface EmbedPayload {
/** HTML string to render inside the embed iframe. */
html: string;
/** Height of the embed in pixels. Defaults to 200. */
height?: number;
}DissentInitOptions
typescript
interface DissentInitOptions {
/** Called if no dissent:init is received within 3 seconds (running outside Dissent). */
onFallback?: () => void;
}Personal-plugin types
typescript
type StorageScope = 'server' | 'user';
type GameSavesStatus =
| 'ok' | 'desktop_only' | 'no_game_data' | 'no_current_run' | 'unsupported_version'
| 'unsupported_coop' | 'unreadable' | 'not_found' | 'unsupported_game';
/** The other fields depend on the game; see Game Saves. */
type GameSavesAnswer = { status: GameSavesStatus } & Record<string, unknown>;
interface OverlayContext {
game: string;
surface: string;
width: number;
height: number;
/** The overlay's panel layer is open, so this frame is visible. */
panelOpen: boolean;
}Error handling
A method that the host refuses rejects with an Error whose message is the host's reason. Wrap calls in try/catch:
javascript
try {
const res = await Dissent.fetch('https://api.example.com/data');
} catch (err) {
console.error('Fetch failed:', err.message);
// Gracefully degrade
}Messages you will see:
<permission> not granted— the user did not grant it. Checkctx.permissionsfirst.<permission> is no longer declared by this plugin— the user granted it once, but the installed plugin no longer asks for it.<action> is not available to personal plugins— a personal plugin called something outside its lane.Dissent SDK: request "<action>" timed out— no answer within 10 seconds (20 seconds fornet.fetch, 2 minutes for wallet connect and signing).