Skip to content

πŸŽ₯ Make videos programmatically with React

Documentation about browser rendering

JonnyBurger4b554b837216
diff --git a/bun.lock b/bun.lock
index 83ea1a9a35..a0afd3e68e 100644
--- a/bun.lock
+++ b/bun.lock
@@ -404,6 +404,7 @@
"@remotion/tailwind-v4": "workspace:*",
"@remotion/three": "workspace:*",
"@remotion/transitions": "workspace:*",
+ "@remotion/web-renderer": "workspace:*",
"@remotion/webcodecs": "workspace:*",
"@remotion/whisper-web": "workspace:*",
"@remotion/zod-types": "workspace:*",
diff --git a/packages/docs/docs/client-side-rendering/how-it-works.mdx b/packages/docs/docs/client-side-rendering/how-it-works.mdx
new file mode 100644
index 0000000000..8e0c459849
--- /dev/null
+++ b/packages/docs/docs/client-side-rendering/how-it-works.mdx
@@ -0,0 +1,52 @@
+---
+image: /generated/articles-docs-client-side-rendering-how-it-works.png
+crumb: 'Client-side rendering'
+sidebar_label: Mechanism
+title: How client-side rendering works
+---
+
+:::warning
+This feature is not available yet, but we are already writing docs.
+[Track progress on GitHub](https://github.com/remotion-dev/remotion/issues/5913) and discuss in the [`#web-renderer`](https://remotion.dev/discord) channel on Discord.
+:::
+
+The biggest challenge of client-side rendering is that it is not possible to capture the browser viewport.
+Only certain HTML elements and React components such as `<canvas>`, `<svg>`, [`<Video>`](/docs/media/video), [`<Audio>`](/docs/media/audio), and [`<Img>`](/docs/img) can be captured.
+
+Unlike in server-side rendering, where a pixel-perfect screenshot is made, in client-side rendering Remotion only takes the capturable elements and composites them onto a single canvas.
+
+## Rendering process
+
+### Initialization
+
+First, the component is mounted in the DOM in a place where it is not visible to the user.
+
+### Frame capture process
+
+For each frame that needs to be rendered, the renderer uses `element.querySelectorAll()` to find all elements that can be captured, including `<canvas>`, `<svg>`, `<Audio>`, `<Video>`, `<img>` and other supported element types.
+
+For each capturable element, the renderer:
+
+1. Goes up the DOM tree and resets all `transform` CSS properties to `none`.
+2. Gets the bounding box using `.getBoundingClientRect()`, as well as the bounding boxes of the parent elements.
+3. Adds up the transforms and positions to determine the original placement of the element in the DOM.
+4. Captures the pixels of the element
+5. Draws them to the canvas according to the calculated placement.
+
+In addition, audio from mounted [`<Audio>`](/docs/media/audio) and [`<Video>`](/docs/media/video) elements is captured and mixed, and added to the audio track of the video.
+
+### Encoding
+
+[Mediabunny](/docs/mediabunny) is used to encode the frames and processed audio into a video file.
+
+## Context isolation
+
+Renders happen in the same browser environment as your app. This means CSS and Tailwind variables will automatically work, but you run the risk of conflicts with the host page.
+
+See [Limitations](/docs/client-side-rendering/limitations) for more details to ensure your code works with client-side rendering.
+
+## See also
+
+- [Client-side rendering](/docs/client-side-rendering/overview)
+- [Limitations](/docs/client-side-rendering/limitations)
+- [Mediabunny](/docs/mediabunny)
diff --git a/packages/docs/docs/client-side-rendering/index.mdx b/packages/docs/docs/client-side-rendering/index.mdx
new file mode 100644
index 0000000000..f2dce55326
--- /dev/null
+++ b/packages/docs/docs/client-side-rendering/index.mdx
@@ -0,0 +1,64 @@
+---
+image: /generated/articles-docs-client-side-rendering-index.png
+crumb: 'Overview'
+sidebar_label: Overview
+title: Client-side rendering
+---
+
+:::warning
+This feature is not available yet, but we are already writing docs.
+[Track progress on GitHub](https://github.com/remotion-dev/remotion/issues/5913) and discuss in the [`#web-renderer`](https://remotion.dev/discord) channel on Discord.
+:::
+
+Client-side rendering is a new additional capability of Remotion that allows you to render videos, images, and audio directly in the browser, without requiring server-side infrastructure.
+
+It is currently in development and will be released as a new package called `@remotion/web-renderer`.
+
+## Key differences from server-side rendering
+
+Unlike server-side rendering with [`@remotion/renderer`](/docs/renderer), client-side rendering:
+
+- Runs in the browser - No need to setup Node servers or Remotion Lambda
+- Encodes with WebCodecs using [Mediabunny](/docs/mediabunny) instead of FFmpeg
+- Limited to a subset of HTML elements - see [limitations](/docs/client-side-rendering/limitations)
+- No bundling step - takes components and video config directly
+
+## APIs
+
+The package will provide APIs called `renderStillOnWeb()` and `renderMediaOnWeb()`.
+
+Here is an example of how to use it:
+
+```tsx twoslash title="Tentative API example"
+import {renderStillOnWeb} from '@remotion/web-renderer';
+
+const Component: React.FC = () => {
+ return (
+ <svg viewBox="0 0 100 100" width="100" height="100" style={{transform: 'rotate(45deg)'}}>
+ <polygon points="50,10 90,90 10,90" fill="orange" />
+ </svg>
+ );
+};
+
+const blob = await renderStillOnWeb({
+ component: Component,
+ durationInFrames: 100,
+ fps: 30,
+ width: 100,
+ height: 100,
+ frame: 0,
+ inputProps: {},
+});
+```
+
+## Status
+
+Client-side rendering is currently in active development.
+
+[View the current status and progress β†’](https://github.com/remotion-dev/remotion/issues/5913)
+
+## See also
+
+- [How it works](/docs/client-side-rendering/how-it-works)
+- [Limitations](/docs/client-side-rendering/limitations)
+- [Server-side rendering](/docs/ssr)
diff --git a/packages/docs/docs/client-side-rendering/limitations.mdx b/packages/docs/docs/client-side-rendering/limitations.mdx
new file mode 100644
index 0000000000..4695200fd0
--- /dev/null
+++ b/packages/docs/docs/client-side-rendering/limitations.mdx
@@ -0,0 +1,116 @@
+---
+image: /generated/articles-docs-client-side-rendering-limitations.png
+crumb: 'Client-side rendering'
+sidebar_label: Limitations
+title: Limitations of client-side rendering
+---
+
+:::warning
+This feature is not available yet, but we are already writing docs.
+[Track progress on GitHub](https://github.com/remotion-dev/remotion/issues/5913) and discuss in the [`#web-renderer`](https://remotion.dev/discord) channel on Discord.
+:::
+
+Client-side rendering has several limitations to be aware of.
+
+## Supported element types
+
+Only certain element types can be captured and rendered:
+
+- `<canvas>` elements
+- `<svg>` elements
+- [`<Img>`](/docs/img) elements - supported, but subject to CORS restrictions
+- [`<Audio>`](/docs/media/audio) elements
+- [`<Video>`](/docs/media/video) elements
+- [`<Gif>`](/docs/gif), [`<AnimatedImage>`](/docs/animated-image), [`<Lottie>`](/docs/lottie), [`<Rive>`](/docs/rive) elements
+
+You can use HTML elements like `<div>` to influence the layout of the elements, but they will not be captured visually
+
+```tsx
+import {AbsoluteFill, Img} from 'remotion';
+
+export const MyComponent: React.FC = () => {
+ return (
+ /* Using Flexbox to center the elements is supported */
+ <div style={{display: 'flex', flexDirection: 'row', justifyContent: 'center', alignItems: 'center'}}>
+ {/** This text will NOT be captured but it influences the layout */}
+ <div>Hello world</div>
+ {/** This image WILL be captured because it is a supported element type */}
+ <Img style={staticFile('image.png')} />
+ </div>
+ );
+};
+```
+
+## Uncapturable elements and styles
+
+Every element that is not explicitly supported is unsupported. Some important ones are:
+
+<!-- TODO: Block Html5Video from being used -->
+
+- `<Html5Video>`, `<Html5Audio>` and `<OffthreadVideo>` from the `remotion` package
+- Text elements: `<div>`, `<span>`, `<h1>`, etc.
+
+In addition, CSS styles are not supported, except ones that change the layout of the element, such as `margin`, `left`, `transform`, etc.
+
+```tsx twoslash title="❌ Doesn't work: Cannot capture styles that don't change the layout"
+<canvas style={{backgroundColor: 'red'}} />
+```
+
+```tsx twoslash title="βœ… Works: Styles that change the layout"
+<canvas style={{position: 'absolute', top: 100, left: 100}} />
+```
+
+One exception is `<svg>` elements, which can be styled.
+
+```tsx twoslash title="βœ… Works: SVG elements can be styled with CSS"
+<svg style={{backgroundColor: 'red'}}>
+ <rect width="100%" height="100%" />
+</svg>
+```
+
+To get a better understanding of what works and what doesn't, read [how client-side rendering works](/docs/client-side-rendering/how-it-works) under the hood.
+
+## Z-indexing
+
+Is not implemented and `zIndex` CSS properties are ignored.
+The rule is: Elements which are further down in the markup last will be on top.
+
+```tsx twoslash title="The blue square will be drawn on top of the red square"
+import {AbsoluteFill} from 'remotion';
+
+// ---cut---
+const MyComp = () => {
+ return (
+ <AbsoluteFill>
+ <AbsoluteFill>
+ <svg viewBox="0 0 100 100">
+ <rect x="0" y="0" width="100" height="100" fill="red" />
+ </svg>
+ </AbsoluteFill>
+ <AbsoluteFill>
+ <svg viewBox="0 0 100 100">
+ <rect x="0" y="0" width="100" height="100" fill="blue" />
+ </svg>
+ </AbsoluteFill>
+ </AbsoluteFill>
+ );
+};
+```
+
+## Video and media constraints
+
+The limitations from [`@remotion/media`](/docs/media/support) apply.
+
+## Single concurrency
+
+There is no multithreading for client-side rendering.
+However, it is fundamentally more efficient because there is less interprocess communication.
+In addition, in the headful browser, GPU is usually available, which brings performance benefits.
+
+## See also
+
+- [Overview](/docs/client-side-rendering/overview)
+- [How it works](/docs/client-side-rendering/how-it-works)
+- [Server-side rendering](/docs/ssr)
+- [`@remotion/renderer`](/docs/renderer)
+- [`Comparing SSR solutions`](/docs/compare-ssr)
diff --git a/packages/docs/docs/miscellaneous/render-in-browser.mdx b/packages/docs/docs/miscellaneous/render-in-browser.mdx
index 598e71b4be..12b9f6b7b1 100644
--- a/packages/docs/docs/miscellaneous/render-in-browser.mdx
+++ b/packages/docs/docs/miscellaneous/render-in-browser.mdx
@@ -10,18 +10,9 @@ In order to render videos, you need to hook up [server-side rendering](/docs/ssr
## Our future plan
-**We are planning to add support for rendering videos in the browser in the future.**
-As of September 2025, this is our biggest priority on the roadmap and the feature is in the works.
+**We are planning to add support for rendering videos in the browser in the future** - with some [limitations](/docs/client-side-rendering/limitations).
+See [Client-side rendering](/docs/client-side-rendering) for an overview of the project.
-The biggest limitation is that there is no way to capture the browser viewport.
-
-Therefore, with browser rendering, only certain tags will be supported, such as `<canvas>`, `<svg>`, `<Video>` and `<Img>`. Also, `<Audio>` can be processed.
-
-It will still be possible to layout these tags using `<div>`'s and CSS, since Remotion will be able to programmatically determine the position of the elements.
-Remotion will extract canvas-like elements from the DOM and compose them.
-This keeps the possibility to have event handlers like `onPointerDown` attached to them. We hope this is more productive than to just have one `<canvas>` element and disable event handlers and CSS layouting.
-
-The encoding of the video will work with [Mediabunny](/docs/mediabunny).
We hope to launch this mode in late 2025.
## Future-proofing your code
@@ -29,7 +20,7 @@ We hope to launch this mode in late 2025.
To prepare yourself for client-side rendering, update your code:
- to use the [`useRemotionEnvironment()`](/docs/use-remotion-environment) hook instead of `getRemotionEnvironment()`
-- to use the [`useDelayRender()`](/docs/use-delay-render) hook instead of `delayRender()`
+- to use the [`useDelayRender()`](/docs/use-delay-render) hook instead of `delayRender()`, `continueRender()` and `cancelRender()`
- Ensure your assets are available via CORS, so the client-side can access them
## See also
diff --git a/packages/docs/package.json b/packages/docs/package.json
index f71b67117e..7b648715bd 100644
--- a/packages/docs/package.json
+++ b/packages/docs/package.json
@@ -77,6 +77,7 @@
"@remotion/transitions": "workspace:*",
"@remotion/webcodecs": "workspace:*",
"@remotion/whisper-web": "workspace:*",
+ "@remotion/web-renderer": "workspace:*",
"@remotion/zod-types": "workspace:*",
"@rive-app/canvas-advanced": "2.31.5",
"@shopify/react-native-skia": "2.0.0",
diff --git a/packages/docs/sidebars.ts b/packages/docs/sidebars.ts
index 4e9e479c4d..2af50c4710 100644
--- a/packages/docs/sidebars.ts
+++ b/packages/docs/sidebars.ts
@@ -938,6 +938,19 @@ const sidebars: SidebarsConfig = {
'azure-container-apps',
],
},
+ {
+ type: 'category',
+ label: 'Client-side rendering',
+ link: {
+ type: 'doc',
+ id: 'client-side-rendering/index',
+ },
+ items: [
+ 'client-side-rendering/index',
+ 'client-side-rendering/how-it-works',
+ 'client-side-rendering/limitations',
+ ],
+ },
{
type: 'category',
link: {
diff --git a/packages/docs/src/data/articles.ts b/packages/docs/src/data/articles.ts
index c4a499b23d..3ea8006bde 100644
--- a/packages/docs/src/data/articles.ts
+++ b/packages/docs/src/data/articles.ts
@@ -656,6 +656,33 @@ export const articles = [
noAi: false,
slug: 'cli/versions',
},
+ {
+ id: 'client-side-rendering/how-it-works',
+ title: 'How client-side rendering works',
+ relativePath: 'docs/client-side-rendering/how-it-works.mdx',
+ compId: 'articles-docs-client-side-rendering-how-it-works',
+ crumb: 'Client-side rendering',
+ noAi: false,
+ slug: 'client-side-rendering/how-it-works',
+ },
+ {
+ id: 'client-side-rendering/index',
+ title: 'Client-side rendering',
+ relativePath: 'docs/client-side-rendering/index.mdx',
+ compId: 'articles-docs-client-side-rendering-index',
+ crumb: 'Overview',
+ noAi: false,
+ slug: 'client-side-rendering/index',
+ },
+ {
+ id: 'client-side-rendering/limitations',
+ title: 'Limitations of client-side rendering',
+ relativePath: 'docs/client-side-rendering/limitations.mdx',
+ compId: 'articles-docs-client-side-rendering-limitations',
+ crumb: 'Client-side rendering',
+ noAi: false,
+ slug: 'client-side-rendering/limitations',
+ },
{
id: 'clipper',
title: '<Experimental.Clipper>',
@@ -1233,13 +1260,13 @@ export const articles = [
slug: 'deno',
},
{
- id: 'detect-remotion-video',
+ id: 'detect-remotion',
title: 'Detect if a video was made with Remotion',
relativePath: 'docs/detect-remotion.mdx',
compId: 'articles-docs-detect-remotion',
crumb: 'Techniques',
noAi: false,
- slug: 'detect-remotion-video',
+ slug: 'detect-remotion',
},
{
id: 'distributed-rendering',
diff --git a/packages/docs/static/generated/articles-docs-client-side-rendering-how-it-works.png b/packages/docs/static/generated/articles-docs-client-side-rendering-how-it-works.png
new file mode 100644
index 0000000000..56892e493a
Binary files /dev/null and b/packages/docs/static/generated/articles-docs-client-side-rendering-how-it-works.png differ
diff --git a/packages/docs/static/generated/articles-docs-client-side-rendering-index.png b/packages/docs/static/generated/articles-docs-client-side-rendering-index.png
new file mode 100644
index 0000000000..f6b066f8fa
Binary files /dev/null and b/packages/docs/static/generated/articles-docs-client-side-rendering-index.png differ
diff --git a/packages/docs/static/generated/articles-docs-client-side-rendering-limitations.png b/packages/docs/static/generated/articles-docs-client-side-rendering-limitations.png
new file mode 100644
index 0000000000..57ea70caa6
Binary files /dev/null and b/packages/docs/static/generated/articles-docs-client-side-rendering-limitations.png differ