Skip to content

Write HTML. Render video. Built for agents.

docs(concepts): clarify what can and can't be a variable

Jamesd28c0824168b
diff --git a/docs/concepts/variables.mdx b/docs/concepts/variables.mdx
index 81586a0151..2dbb624db5 100644
--- a/docs/concepts/variables.mdx
+++ b/docs/concepts/variables.mdx
@@ -34,6 +34,64 @@ Every declaration requires four fields: `id`, `type`, `label`, and `default`. `i
The Studio editing UI uses `label`, `type`, and the type-specific options to render the right input widget for each variable.
+## What can be a variable
+
+Variables come in two layers. The five [declared types](#variable-types) above cover typed primitive data — strings, numbers, colors, booleans, enums. For everything else, a `string` variable holding a URL is the escape hatch: your composition reads the URL and assigns it to whatever DOM element needs it.
+
+### Parameterizing media assets
+
+The same composition can render different images, video clips, or audio tracks just by swapping URLs through a string variable:
+
+```html compositions/product-card.html
+<html data-composition-variables='[
+ {"id":"productImage","type":"string","label":"Product image URL","default":"https://cdn.example.com/products/default.png"},
+ {"id":"productName","type":"string","label":"Product name","default":"Untitled"}
+]'>
+ <body>
+ <div data-composition-id="product-card" data-width="1920" data-height="1080" data-duration="5">
+ <img class="product-img" alt="" />
+ <h1 class="product-name"></h1>
+
+ <script>
+ const {
+ productImage = "https://cdn.example.com/products/default.png",
+ productName = "Untitled",
+ } = __hyperframes.getVariables();
+ const root = document.querySelector('[data-composition-id="product-card"]');
+ root.querySelector(".product-img").src = productImage;
+ root.querySelector(".product-name").textContent = productName;
+ </script>
+ </div>
+ </body>
+</html>
+```
+
+<Note>
+The runtime probes the DOM after your composition script runs, so a `<video>` or `<audio>` `src` assigned at runtime from a variable is discovered and pre-extracted for the render. No extra wiring required — just set the `src` from your variable.
+</Note>
+
+The same pattern covers the three media element types:
+
+- **`<img src>`** — assign from a string variable. Chrome fetches it during capture like any other image; no extra config.
+- **`<video src>`** — assign from a string variable, but keep the timing attributes (`data-start`, `data-duration`, `data-track-index`, `data-has-audio`) on the element itself. The probe phase scans `video[data-start]` elements after your script runs and reads the resolved `src` for pre-extraction.
+- **`<audio src>`** — same as video. The audio is decoded during capture and mixed into the final output.
+
+Pass assets as URL references your composition resolves at render time; don't inline base64. URL-shaped assets travel cleanly through both the local renderer and the Lambda surface — see [Templates on Lambda](/deploy/templates-on-lambda#working-with-large-variables) for the 256 KiB execution-input cap on distributed renders.
+
+## What can't be a variable
+
+Some inputs look variable-shaped but are configured elsewhere. The right mechanism for each:
+
+| What | Mechanism (not a variable) |
+|------|----------------------------|
+| Composition duration | `data-duration` attribute on the composition element |
+| Composition dimensions | `data-width` / `data-height` attributes |
+| Frame rate | `--fps` flag on `hyperframes render` |
+| Output format / codec / quality | `--format` / `--codec` / `--quality` flags |
+| A sibling or parent composition's variables | Variables are per-composition; use [`data-variable-values`](#per-instance-overrides-sub-compositions) on each sub-comp host element to pass overrides |
+
+The deeper rule: variables are runtime values, not authoring inputs. A variable can toggle DOM state, swap text, change a color — anything your composition script does with the resolved value. It can't change the composition's structural identity. Two compositions with different `data-composition-id` or different layout markup remain different compositions, even when their variable values are identical.
+
## Reading Variables at Runtime
Inside any composition script, call `window.__hyperframes.getVariables()` to get the resolved variable values. The return type is `Partial<Record<string, unknown>>` — use destructuring with defaults matching the declared `default` values:
diff --git a/docs/deploy/aws-lambda.mdx b/docs/deploy/aws-lambda.mdx
index 5b232b7e2f..cb879bedc8 100644
--- a/docs/deploy/aws-lambda.mdx
+++ b/docs/deploy/aws-lambda.mdx
@@ -11,6 +11,8 @@ hyperframes lambda render ./my-project --width 1920 --height 1080 --wait
hyperframes lambda destroy
```
+Templates with [variables](/concepts/variables) work on the same Lambda stack — declare `data-composition-variables` on the composition, then pass values per render with `--variables` or fan a whole batch out with `lambda render-batch`. See the [Templates on Lambda](/deploy/templates-on-lambda) guide for the personalised-render pipeline (single render, batch from JSONL, programmatic SDK) and the 256 KiB Step Functions execution-input cap.
+
## Architecture
```
diff --git a/docs/deploy/migrating-to-hyperframes-lambda.mdx b/docs/deploy/migrating-to-hyperframes-lambda.mdx
index bb66b36a95..9c15d598ca 100644
--- a/docs/deploy/migrating-to-hyperframes-lambda.mdx
+++ b/docs/deploy/migrating-to-hyperframes-lambda.mdx
@@ -48,6 +48,12 @@ Most adopters' render config maps directly:
| Max parallel chunks | `--max-parallel-chunks=16` (default 16) | Caps the Map state's fan-out. |
| Bitrate / CRF | `--bitrate=10M` or `--crf=18` | Mutually exclusive. |
+## Variables (inputProps)
+
+Render-time payloads — `inputProps` in some frameworks, `variables` in HyperFrames — are isomorphic. Declare the composition's variable shape on the root `<html>` element via `data-composition-variables`, then pass per-render values with `hyperframes render --variables '{...}'` locally or `hyperframes lambda render --variables` on the Lambda surface. The same 256 KiB execution-input cap and "URL your assets, don't inline base64" convention apply.
+
+The full mapping — `defaultProps` → declarations, `useCurrentFrame()` + `props.<x>` → `__hyperframes.getVariables().<x>`, `renderMediaOnLambda({ inputProps })` → `renderToLambda({ config: { variables } })` — lives in [Templates on Lambda](/deploy/templates-on-lambda#migrating-from-remotion-lambda-inputprops).
+
## What HyperFrames does differently
A few areas where the contract is intentionally different from comparable frameworks. Surface them up front so the migration doesn't surprise you mid-deploy.