π₯ Make videos programmatically with React
more links in the docs
JonnyBurgere3573af0b491
diff --git a/packages/docs/docs/client-side-rendering/html-in-canvas.mdx b/packages/docs/docs/client-side-rendering/html-in-canvas.mdxindex 9eef4ddd2f..163a0aac42 100644--- a/packages/docs/docs/client-side-rendering/html-in-canvas.mdx+++ b/packages/docs/docs/client-side-rendering/html-in-canvas.mdx@@ -15,7 +15,7 @@ Experimental feature - expect bugs and breaking changes at any time.On supported Chromium-based browsers, [`@remotion/web-renderer`](/docs/web-renderer) can optionally capture full frames using the experimental [HTML-in-canvas](https://github.com/WICG/html-in-canvas) APIs.:::info-As of April 2026, this feature requires [Chrome Canary](https://www.google.com/chrome/canary/). Regular Chrome has partial support (`drawElementImage`) but is missing `canvas.requestPaint()`, which can cause rendering issues such as frames being repeated. See [Compatibility](#compatibility) for details.+As of April 2026, this feature requires [Chrome Canary](https://www.google.com/chrome/canary/). Regular Chrome has partial support ([`drawElementImage`](https://github.com/WICG/html-in-canvas#2-drawelementimage-and-webglwebgpu-equivalents)) but is missing `canvas.requestPaint()`, which can cause rendering issues such as frames being repeated. See [Compatibility](#compatibility) for details.:::Enabling the option does not guarantee that this path runs. If the browser does not have HTML-in-canvas enabled, it falls back to the [default frame capturing mechanism](/docs/client-side-rendering/how-it-works).@@ -100,7 +100,7 @@ If HTML-in-canvas is not available, or not allowed, no warning will be printed.HTML-in-canvas depends on Chromium flag `chrome://flags/#canvas-draw-element` which needs to be explicitly enabled as of time of writing in April 2026.-As of April 2026, [Chrome Canary](https://www.google.com/chrome/canary/) is required for full support. Regular Chrome exposes `drawElementImage` when the flag is enabled, but does not yet ship `canvas.requestPaint()`. Without `requestPaint()`, the renderer cannot synchronize paint operations, which can lead to repeated or incorrect frames.+As of April 2026, [Chrome Canary](https://www.google.com/chrome/canary/) is required for full support. Regular Chrome exposes [`drawElementImage`](https://github.com/WICG/html-in-canvas#2-drawelementimage-and-webglwebgpu-equivalents) when the flag is enabled, but does not yet ship `canvas.requestPaint()`. Without `requestPaint()`, the renderer cannot synchronize paint operations, which can lead to repeated or incorrect frames.## See alsodiff --git a/packages/docs/docs/contributing/presentation.mdx b/packages/docs/docs/contributing/presentation.mdxindex a904da6ba7..320bb2da6f 100644--- a/packages/docs/docs/contributing/presentation.mdx+++ b/packages/docs/docs/contributing/presentation.mdx@@ -78,7 +78,7 @@ See [Custom HTML-in-canvas presentations](/docs/transitions/presentations/customIf you want to contribute the presentations back into the `@remotion/transitions` package:-<Step>1</Step> Author the shader using <a href="/docs/transitions/make-html-in-canvas-presentation"><code>makeHtmlInCanvasPresentation()</code></a> and the <code>HtmlInCanvasShader<Props></code> type. See <a href="https://github.com/remotion-dev/remotion/blob/main/packages/transitions/src/presentations/zoom-blur.tsx"><code>zoom-blur.tsx</code></a> as a reference.<br />+<Step>1</Step> Author the shader using <a href="/docs/transitions/make-html-in-canvas-presentation"><code>makeHtmlInCanvasPresentation()</code></a> and the <a href="/docs/transitions/make-html-in-canvas-presentation#htmlincanvasshader"><code>HtmlInCanvasShader<Props></code></a> type. See <a href="https://github.com/remotion-dev/remotion/blob/main/packages/transitions/src/presentations/zoom-blur.tsx"><code>zoom-blur.tsx</code></a> as a reference.<br /><Step>2</Step> [gl-transitions.com](https://gl-transitions.com/) is a great source of MIT-licensed fragment shaders that can be ported. Always credit the original author and the MIT license in a comment above the shader source. <a href="https://github.com/remotion-dev/remotion/blob/main/packages/transitions/src/presentations/zoom-in-out.tsx"><code>zoom-in-out.tsx</code></a> is an example of a port.<br /><Step>3</Step> Mind the time convention: in our shaders <code>u_time = 0</code> outputs the entering scene and <code>u_time = 1</code> outputs the exiting scene. When porting from gl-transitions, set <code>float progress = 1.0 - u_time;</code> at the top of <code>main()</code>.<br /><Step>4</Step> Handle the boundary cases inside the JS <code>draw()</code> function: when <code>prevImage</code> is <code>null</code>, force <code>time = 0</code>; when <code>nextImage</code> is <code>null</code>, force <code>time = 1</code>.<br />diff --git a/packages/docs/docs/remotion/html-in-canvas.mdx b/packages/docs/docs/remotion/html-in-canvas.mdxindex da3a66cd99..0500f40a09 100644--- a/packages/docs/docs/remotion/html-in-canvas.mdx+++ b/packages/docs/docs/remotion/html-in-canvas.mdx@@ -88,11 +88,11 @@ You should paint to this canvas.#### `element`The inner [`HTMLDivElement`](https://developer.mozilla.org/en-US/docs/Web/API/HTMLDivElement) that wraps `children`.-You should apply the return value of `drawElementImage` to this element's `style.transform` property.+You should apply the return value of [`drawElementImage`](https://github.com/WICG/html-in-canvas#2-drawelementimage-and-webglwebgpu-equivalents) to this element's `style.transform` property.#### `elementImage`-An [`ElementImage`](https://github.com/WICG/html-in-canvas) handle for the current capture.+An [`ElementImage`](https://github.com/WICG/html-in-canvas#idl-changes) handle for the current capture.You should paint this image to the canvas.### `onInit?`@@ -135,7 +135,7 @@ export const Example: React.FC = () => {### 2D-Call [`drawElementImage()`](https://github.com/WICG/html-in-canvas) on the 2D context to draw `elementImage` into the bitmap.+Call [`drawElementImage()`](https://github.com/WICG/html-in-canvas#2-drawelementimage-and-webglwebgpu-equivalents) on the 2D context to draw `elementImage` into the bitmap.HTML-in-canvas recommends that you use the return value and assign it to `element.style.transform`, so that the original DOM element matches the transform, so that selection still works.For 2D, you usually do not need `onInit`.@@ -204,7 +204,7 @@ export const HtmlInCanvas2DBlur: React.FC = () => {Do all setup in [`onInit`](#oninit) such as getting the WebGL context and compiling the shader.`onInit` must return a cleanup function that destroys the resources that were created in `onInit`.-Use [`texElementImage2D`](https://github.com/WICG/html-in-canvas) to turn the `elementImage` into a texture.+Use [`texElementImage2D`](https://github.com/WICG/html-in-canvas#2-drawelementimage-and-webglwebgpu-equivalents) to turn the `elementImage` into a texture.<Demo type="html-in-canvas-webgl" />@@ -398,7 +398,7 @@ export const HtmlInCanvasDocsMinimalWebGL: React.FC = () => {Use [`onInit`](#oninit) to get a WebGPU context, to request a GPU and to compile shaders.`onInit` must return a cleanup function that destroys the resources that were created in `onInit`.-In `onPaint`, draw the `elementImage` to the canvas using `copyElementImageToTexture`.+In `onPaint`, draw the `elementImage` to the canvas using [`copyElementImageToTexture`](https://github.com/WICG/html-in-canvas#2-drawelementimage-and-webglwebgpu-equivalents).<Demo type="html-in-canvas-webgpu" />diff --git a/packages/docs/docs/transitions/make-html-in-canvas-presentation.mdx b/packages/docs/docs/transitions/make-html-in-canvas-presentation.mdxindex 1fa1a0666e..7e33bfd844 100644--- a/packages/docs/docs/transitions/make-html-in-canvas-presentation.mdx+++ b/packages/docs/docs/transitions/make-html-in-canvas-presentation.mdx@@ -240,16 +240,9 @@ HTML-in-canvas requires [Chrome Canary](https://www.google.com/chrome/canary/) w### `shader`-A function of type `HtmlInCanvasShader<Props>`.+A function of type [`HtmlInCanvasShader<Props>`](#htmlincanvasshader).Must return an object with three callbacks: `clear`, `cleanup` and `draw`.-```ts twoslash-import type {- HtmlInCanvasShader,- // ^?-} from '@remotion/transitions';-```-#### `clear()`Called when there is nothing to draw (both scenes are unmounted).@@ -262,31 +255,16 @@ Release any GL resources you allocated.#### `draw()`-Called every frame the transition is active. Has the type `HtmlInCanvasShaderDraw<Props>`:--```ts twoslash-import type {- HtmlInCanvasShaderDraw,- // ^?-} from '@remotion/transitions';-```--The argument has the type `HtmlInCanvasShaderDrawParams<Props>`:--```ts twoslash-import type {- HtmlInCanvasShaderDrawParams,- // ^?-} from '@remotion/transitions';-```+Called every frame the transition is active.+Has the type [`HtmlInCanvasShaderDraw<Props>`](#htmlincanvasshaderdraw); the argument has the type [`HtmlInCanvasShaderDrawParams<Props>`](#htmlincanvasshaderdrawparams).##### `prevImage`-`ElementImage | null` β the captured exiting scene. `null` while it has not yet rendered (e.g. at the very start).+[`ElementImage`](https://github.com/WICG/html-in-canvas#idl-changes)` | null` β the captured exiting scene. `null` while it has not yet rendered (e.g. at the very start).##### `nextImage`-`ElementImage | null` β the captured entering scene. `null` after the entering scene has unmounted.+[`ElementImage`](https://github.com/WICG/html-in-canvas#idl-changes)` | null` β the captured entering scene. `null` after the entering scene has unmounted.##### `width` / `height`@@ -308,6 +286,35 @@ Whatever you typed your `Props` as.A `presentation` that you can pass to a [`<TransitionSeries.Transition>`](/docs/transitions/transitionseries#transitionseriestransition).+## Types++### `HtmlInCanvasShader`++```ts twoslash+import type {+ HtmlInCanvasShader,+ // ^?+} from '@remotion/transitions';+```++### `HtmlInCanvasShaderDraw`++```ts twoslash+import type {+ HtmlInCanvasShaderDraw,+ // ^?+} from '@remotion/transitions';+```++### `HtmlInCanvasShaderDrawParams`++```ts twoslash+import type {+ HtmlInCanvasShaderDrawParams,+ // ^?+} from '@remotion/transitions';+```+## See also- [Custom HTML-in-canvas presentations](/docs/transitions/presentations/custom-html-in-canvas) β full walkthrough and examplediff --git a/packages/docs/docs/transitions/presentations/custom-html-in-canvas.mdx b/packages/docs/docs/transitions/presentations/custom-html-in-canvas.mdxindex 5bc2785649..27d6db93aa 100644--- a/packages/docs/docs/transitions/presentations/custom-html-in-canvas.mdx+++ b/packages/docs/docs/transitions/presentations/custom-html-in-canvas.mdx@@ -9,23 +9,19 @@ title: 'Custom HTML-in-canvas presentations'Build a presentation that runs the entering and exiting scenes through a WebGL2 fragment shader using the experimental [HTML-in-canvas](https://github.com/WICG/html-in-canvas) APIs.:::warning-HTML-in-canvas requires [Chrome Canary](https://www.google.com/chrome/canary/) with `chrome://flags/#canvas-draw-element` enabled in the browser. For server-side renders, pass `--allow-html-in-canvas` (or [`Config.setAllowHtmlInCanvasEnabled(true)`](/docs/config#setallowhtmlincanvasenabled)). It does not work in Firefox or Safari.+HTML-in-canvas requires [Chrome Canary](https://www.google.com/chrome/canary/) with `chrome://flags/#canvas-draw-element` enabled in the browser.:::## When to use this-Use a custom HTML-in-canvas presentation when:--- Your effect needs both scenes blended pixel-by-pixel through a fragment shader (zoom blur, dissolves, displacement maps, ripple, page curl, etc.)-- The CSS-only approach in [Custom presentations](/docs/transitions/presentations/custom) cannot express the effect--If a CSS `clip-path`, `transform`, `filter` or `mask` can express the effect, prefer the [CSS-based custom presentation](/docs/transitions/presentations/custom). It works in every browser and renderer.+Use this when you cannot implement the presentation in CSS.+Prefer CSS because it has wider browser support.## Concept-Remotion captures both scenes via `drawElementImage()` and passes them to your shader as two `ElementImage` textures (`prevImage` and `nextImage`) along with the transition `time` (`0` β `1`). Your shader writes the blended result to an offscreen WebGL2 canvas, which Remotion then composites into the frame.+Remotion captures both scenes via [`captureElementImage()`](https://github.com/WICG/html-in-canvas#4-captureelementimage) and passes them to your shader as two [`ElementImage`](https://github.com/WICG/html-in-canvas#idl-changes) handles (`prevImage` and `nextImage`) along with the transition `time` (`0` β `1`). Your shader uploads them as textures via [`drawElementImage()`](https://github.com/WICG/html-in-canvas#2-drawelementimage-and-webglwebgpu-equivalents) (or its WebGL/WebGPU equivalents) and writes the blended result to an offscreen WebGL2 canvas, which Remotion then composites into the frame.-You implement a single function β `HtmlInCanvasShader<Props>` β and pass it to [`makeHtmlInCanvasPresentation()`](/docs/transitions/make-html-in-canvas-presentation) to get back a `TransitionPresentation` constructor.+You implement a single function β [`HtmlInCanvasShader<Props>`](/docs/transitions/make-html-in-canvas-presentation#htmlincanvasshader) β and pass it to [`makeHtmlInCanvasPresentation()`](/docs/transitions/make-html-in-canvas-presentation) to get back a `TransitionPresentation` constructor.## Boilerplate@@ -121,7 +117,7 @@ export const MyComp: React.FC = () => {## API reference-The signature of [`makeHtmlInCanvasPresentation()`](/docs/transitions/make-html-in-canvas-presentation) and the `HtmlInCanvasShader<Props>` callback contract β `clear`, `cleanup`, `draw({prevImage, nextImage, width, height, time, passedProps})` β are documented on its own page.+The signature of [`makeHtmlInCanvasPresentation()`](/docs/transitions/make-html-in-canvas-presentation) and the [`HtmlInCanvasShader<Props>`](/docs/transitions/make-html-in-canvas-presentation#htmlincanvasshader) callback contract β `clear`, `cleanup`, [`draw({prevImage, nextImage, width, height, time, passedProps})`](/docs/transitions/make-html-in-canvas-presentation#draw) β are documented on its own page.## Adapting GLSL transitions from gl-transitions.com