OverrideSet) alongside it. When a user edits their instance, the SDK accumulates further changes into that same delta — the base stays untouched.
This is exactly how a canvas embedder (for example, AI Studio) persists in-composition edits as a stable, reopenable delta.
Opening with overrides
Pass the stored delta asoverrides when you call openComposition. The SDK applies the saved changes to the base template, so the session exposes the user’s exact edited state immediately:
openComposition returns, comp.getElements() reflects the overridden state. Any further edits accumulate into the same delta automatically.
Reading the current delta
CallgetOverrides() to retrieve the current delta for storage. It returns a copy ready to serialize and save:
nextOverrides as overrides again — the user sees their exact state.
Elements inserted with addElement() are stored in the delta too, including their
parent and sibling position. Later text, style, or attribute edits replay onto the
restored element:
getOverrides() saves each added or restored element’s current position among
all child nodes, including surrounding text. Removing a temporary sibling does
not shift the element when reopened.
Store the returned set without sorting its keys. The SDK keeps the latest edit
order so later child edits apply after their parent’s snapshot.
Override set key format
Keys follow the patternhfId.prop.path. The common forms are:
A
null value is a removal marker. When the SDK serializes the composition it omits that element entirely. This lets the host distinguish “never touched” (key absent) from “user deleted” (key present, value null).
Sub-composition elements use scoped IDs — "hf-host/hf-leaf.text" — where the host and leaf are separated by /.
Periods in an authored ID stay part of that ID: editing hf-title.main produces
"hf-title.main.text", which restores the edit to that same element when reopened.
Non-null whole-element values must be snapshots returned by getOverrides(). Opening a
delta skips scalar values and incomplete snapshots under whole-element keys.
Font and image variable overrides
Variable overrides (fromsetVariableValue) live under the var.{id} key. Font and image values are objects, not strings:
OverrideSet value at a var.* key, narrow before treating it as a scalar — the type is string | number | boolean | Record<string, unknown> | null.
Disabling SDK undo
In embedded mode the host typically owns the undo stack. The SDK already leaves history off by default in embedded mode (any session opened withoverrides), so you usually don’t need to do anything. Pass history: false explicitly only to make that intent obvious in standalone code paths, or as a guard if a call site may or may not supply overrides:
history: false only disables the SDK’s internal undo stack. Persistence (the persist adapter, if you supply one) is independent — omitting it does not affect autosave. In embedded mode, however, the host typically owns both undo and persistence, so you usually pass neither.Host-owned undo via applyPatches()
When the host pops an undo entry and needs to replay the inverse patches back into the SDK, use applyPatches(). The SDK applies the patches to the live document, updates the internal override set, and emits a patch event tagged with ORIGIN_APPLY_PATCHES.
applyPatches() accepts an optional opts.origin override if you want to tag the event with a different sentinel, but the default ORIGIN_APPLY_PATCHES is the expected value for host undo/redo flows.
See Undo, Redo, and Patches for the full patch event contract and inverse patch handling.
Full example
openComposition reference
Full
OpenCompositionOptions including overrides, history, and persist.Types reference
OverrideSet, FontValue, ImageValue, PatchEvent, and ORIGIN_APPLY_PATCHES.Undo, Redo, and Patches
Patch event format, inverse patch contract, and undo loop prevention.
Canvas integration
Wiring the SDK to a live preview iframe inside an editor canvas.