Skip to content

🎥 Make videos programmatically with React

more docs

Jonny Burger3499b3e8ab25
diff --git a/packages/docs/docs/parametrized-rendering.md b/packages/docs/docs/parametrized-rendering.md
index 6b295bd584..37e31f11c4 100644
--- a/packages/docs/docs/parametrized-rendering.md
+++ b/packages/docs/docs/parametrized-rendering.md
@@ -1,194 +1,69 @@
---
-image: /generated/articles-docs-parametrized-rendering.png
id: parametrized-rendering
-title: Passing props to a composition
+title: Parametrized videos
sidebar_label: Passing props
crumb: "How To"
---
-```twoslash include example
-type Props = {
- propOne: string;
- propTwo: number;
-}
-
-export const MyComponent: React.FC<Props> = ({propOne, propTwo}) => {
- return (
- <div>props: {propOne}, {propTwo}</div>
- );
-}
-// - MyComponent
-```
-
-You can parametrize the content of the videos using [React properties ("props")](https://react.dev/learn/passing-props-to-a-component).
-
-## Defining accepted props
-
-To define which props your video accepts, give your component the `React.FC` type and pass in a generic argument describing the shape of the props you want to accept:
-
-```tsx twoslash title="src/MyComponent.tsx"
-// @include: example-MyComponent
-```
-
-## Define default props
-
-When registering a component that takes props as a composition, you must define default props:
-
-```tsx twoslash {14-17} title="src/Root.tsx"
-// organize-imports-ignore
-
-// @filename: MyComponent.tsx
-import React from "react";
-export const MyComponent: React.FC<{
- propOne: string;
- propTwo: number;
-}> = () => null;
-
-// @filename: Root.tsx
-
-// ---cut---
-import React from "react";
-import { Composition } from "remotion";
-import { MyComponent } from "./MyComponent";
-
-export const Root: React.FC = () => {
- return (
- <>
- <Composition
- id="my-video"
- width={1080}
- height={1080}
- fps={30}
- durationInFrames={30}
- component={MyComponent}
- defaultProps={{
- propOne: "Hi",
- propTwo: 10,
- }}
- />
- </>
- );
-};
-```
-
-Default props are useful so you don't preview your video with no data. [Default props will overriden by input props](/docs/props-resolution).
-
-## Define a schema<AvailableFrom v="4.0.0"/>
-
-You can use [Zod](https://github.com/colinhacks/zod) to [define a typesafe schema for your composition](/docs/schemas).
-
-## Input props
-
-Input props are props that are passed in while invoking a render that can replace or override the default props.
-
-:::note
-Input props must be an object and serializable to JSON.
-:::
-
-### Passing input props in the CLI
-
-When rendering, you can override default props by passing a [CLI](/docs/cli/render) flag. It must be either valid JSON or a path to a file that contains valid JSON.
-
-```bash title="Using inline JSON"
-npx remotion render HelloWorld out/helloworld.mp4 --props='{"propOne": "Hi", "propTwo": 10}'
-```
-
-```bash title="Using a file path"
-npx remotion render HelloWorld out/helloworld.mp4 --props=./path/to/props.json
-```
-
-### Passing input props when using server-side rendering
-
-When server-rendering using [`renderMedia()`](/docs/renderer/render-media) or [`renderMediaOnLambda()`](/docs/lambda/rendermediaonlambda), you can pass props using the [`inputProps`](/docs/renderer/render-media#inputprops) option:
-
-```tsx twoslash {8-10}
-// @module: esnext
-// @target: es2017
-const composition = {
- fps: 30,
- durationInFrames: 30,
- width: 1080,
- height: 1080,
- id: "my-video",
- defaultProps: {},
-};
-const serveUrl = "/path/to/bundle";
-const outputLocation = "/path/to/frames";
-// ---cut---
-import { renderMedia } from "@remotion/renderer";
-
-await renderMedia({
- composition,
- serveUrl,
- codec: "h264",
- outputLocation,
- inputProps: {
- titleText: "Hello World",
- },
-});
-```
-
-### Passing input props in GitHub Actions
-
-[See: Render using GitHub Actions](/docs/ssr#render-using-github-actions)
-
-When using GitHub Actions, you need to adjust the file at `.github/workflows/render-video.yml` to make the inputs in the `workflow_dispatch` section manually match the shape of the props your root component accepts.
-
-```yaml {3, 7}
-workflow_dispatch:
- inputs:
- titleText:
- description: "Which text should it say?"
- required: true
- default: "Welcome to Remotion"
- titleColor:
- description: "Which color should it be in?"
- required: true
- default: "black"
-```
-
-### Retrieve input props
-
-Input props are passed to the [`component`](/docs/composition#component) of your [`<Composition>`](/docs/composition) directly and you can access them like regular React component props.
-
-If you need the input props in your root component, use the [`getInputProps()`](/docs/get-input-props) function to retrieve input props.
-
-## You can still use components normally
-
-Even if a component is registered as a composition, you can still use it like a regular React component and pass the props directly:
-
-```tsx twoslash
-// @include: example-MyComponent
-// ---cut---
-<MyComponent propOne="hi" propTwo={10} />
-```
-
-This is useful if you want to concatenate multiple scenes together. You can use a [`<Series>`](/docs/series) to play two components after each other:
-
-```tsx twoslash title="ChainedScenes.tsx"
-// @include: example-MyComponent
-const AnotherComponent: React.FC = () => {
- return null;
-};
-// ---cut---
-import { Series } from "remotion";
-
-const ChainedScenes = () => {
- return (
- <Series>
- <Series.Sequence durationInFrames={90}>
- <MyComponent propOne="hi" propTwo={10} />
- </Series.Sequence>
- <Series.Sequence durationInFrames={90}>
- <AnotherComponent />
- </Series.Sequence>
- </Series>
- );
-};
-```
-
-You may then register this "Master" component as an additional [`<Composition>`](/docs/the-fundamentals#compositions).
+Remotion allows for [ingesting](/docs/passing-props), [validating](/docs/schemas), [visually editing](/docs/visual-editing), and transforming data that may be used to parametrize a video.
+
+Data may [influence the content](/docs/data-fetching) of the video, or the [metadata](/docs/dynamic-metadata) such as width, height, duration or framerate.
+
+## High-level overview
+
+Remotion allows the passing of [props](https://react.dev/learn/passing-props-to-a-component) to a React component.
+Props are a React concept and take the shape of a JavaScript object.
+
+To determine the data which gets passed to the video, the following steps are taken:
+
+<Step>1</Step> <strong>Default props</strong> are defined statically, so that the video can be designed in the Preview without any data. <br/>
+
+<ul>
+<li>
+The default props define the shape of the data.
+</li>
+<li>
+A schema can be defined and validated.
+</li>
+<li>
+In absence of data, default props can be edited in the Remotion Preview.
+</li>
+</ul>
+<Step>2</Step> <strong>Input props</strong> may be specified when rendering a video to override the default props.<br/>
+<ul>
+<li>
+Input props will be merged together with default props, where input props have priority.
+</li>
+</ul>
+
+<Step>3</Step> <strong>Using <a href="/docs/data-fetching"><code>calculateMetadata()</code></a></strong>, postprocessing of the props may be performed and metadata be dynamically calculated.<br/>
+
+<ul>
+<li>
+For example, given a URL is passed as a prop, it may be fetched and the content added to the props.
+</li>
+<li>
+Asynchronous calculation of the video duration and other metadata is also possible here.
+</li>
+</ul>
+<Step>4</Step> <strong>The final props</strong> are passed to the React component.
+<ul>
+<li>
+The component may dynamically render content based on the props.
+</li>
+</ul>
+
+See [here](/docs/props-resolution) for a visual explanation and more details of how the resolution process works.
+
+## Table of contents
+
+- [Passing props](/docs/passing-props)
+- [Defining a Schema](/docs/schemas)
+- [Visual editing](/docs/visual-editing)
+- [Data fetching](/docs/data-fetching)
+- [Variable metadata](/docs/dynamic-metadata)
+- [How props get resolved](/docs/props-resolution)
## See also
-- [Avoid huge payloads for `defaultProps`](/docs/troubleshooting/defaultprops-too-big)
+You can use the [Remotion Player](/docs/player) to display a Remotion component in a React app and dynamically change the content without rendering the video, to create experiences where the content updates in real-time.
diff --git a/packages/docs/docs/passing-props.md b/packages/docs/docs/passing-props.md
new file mode 100644
index 0000000000..ec6545acb0
--- /dev/null
+++ b/packages/docs/docs/passing-props.md
@@ -0,0 +1,193 @@
+---
+id: passing-props
+title: Passing props to a composition
+sidebar_label: Passing props
+crumb: "How To"
+---
+
+```twoslash include example
+type Props = {
+ propOne: string;
+ propTwo: number;
+}
+
+export const MyComponent: React.FC<Props> = ({propOne, propTwo}) => {
+ return (
+ <div>props: {propOne}, {propTwo}</div>
+ );
+}
+// - MyComponent
+```
+
+You can parametrize the content of the videos using [React properties ("props")](https://react.dev/learn/passing-props-to-a-component).
+
+## Defining accepted props
+
+To define which props your video accepts, give your component the `React.FC` type and pass in a generic argument describing the shape of the props you want to accept:
+
+```tsx twoslash title="src/MyComponent.tsx"
+// @include: example-MyComponent
+```
+
+## Define default props
+
+When registering a component that takes props as a composition, you must define default props:
+
+```tsx twoslash {14-17} title="src/Root.tsx"
+// organize-imports-ignore
+
+// @filename: MyComponent.tsx
+import React from "react";
+export const MyComponent: React.FC<{
+ propOne: string;
+ propTwo: number;
+}> = () => null;
+
+// @filename: Root.tsx
+
+// ---cut---
+import React from "react";
+import { Composition } from "remotion";
+import { MyComponent } from "./MyComponent";
+
+export const Root: React.FC = () => {
+ return (
+ <>
+ <Composition
+ id="my-video"
+ width={1080}
+ height={1080}
+ fps={30}
+ durationInFrames={30}
+ component={MyComponent}
+ defaultProps={{
+ propOne: "Hi",
+ propTwo: 10,
+ }}
+ />
+ </>
+ );
+};
+```
+
+Default props are useful so you don't preview your video with no data. [Default props will overriden by input props](/docs/props-resolution).
+
+## Define a schema<AvailableFrom v="4.0.0"/>
+
+You can use [Zod](https://github.com/colinhacks/zod) to [define a typesafe schema for your composition](/docs/schemas).
+
+## Input props
+
+Input props are props that are passed in while invoking a render that can replace or override the default props.
+
+:::note
+Input props must be an object and serializable to JSON.
+:::
+
+### Passing input props in the CLI
+
+When rendering, you can override default props by passing a [CLI](/docs/cli/render) flag. It must be either valid JSON or a path to a file that contains valid JSON.
+
+```bash title="Using inline JSON"
+npx remotion render HelloWorld out/helloworld.mp4 --props='{"propOne": "Hi", "propTwo": 10}'
+```
+
+```bash title="Using a file path"
+npx remotion render HelloWorld out/helloworld.mp4 --props=./path/to/props.json
+```
+
+### Passing input props when using server-side rendering
+
+When server-rendering using [`renderMedia()`](/docs/renderer/render-media) or [`renderMediaOnLambda()`](/docs/lambda/rendermediaonlambda), you can pass props using the [`inputProps`](/docs/renderer/render-media#inputprops) option:
+
+```tsx twoslash {8-10}
+// @module: esnext
+// @target: es2017
+const composition = {
+ fps: 30,
+ durationInFrames: 30,
+ width: 1080,
+ height: 1080,
+ id: "my-video",
+ defaultProps: {},
+};
+const serveUrl = "/path/to/bundle";
+const outputLocation = "/path/to/frames";
+// ---cut---
+import { renderMedia } from "@remotion/renderer";
+
+await renderMedia({
+ composition,
+ serveUrl,
+ codec: "h264",
+ outputLocation,
+ inputProps: {
+ titleText: "Hello World",
+ },
+});
+```
+
+### Passing input props in GitHub Actions
+
+[See: Render using GitHub Actions](/docs/ssr#render-using-github-actions)
+
+When using GitHub Actions, you need to adjust the file at `.github/workflows/render-video.yml` to make the inputs in the `workflow_dispatch` section manually match the shape of the props your root component accepts.
+
+```yaml {3, 7}
+workflow_dispatch:
+ inputs:
+ titleText:
+ description: "Which text should it say?"
+ required: true
+ default: "Welcome to Remotion"
+ titleColor:
+ description: "Which color should it be in?"
+ required: true
+ default: "black"
+```
+
+### Retrieve input props
+
+Input props are passed to the [`component`](/docs/composition#component) of your [`<Composition>`](/docs/composition) directly and you can access them like regular React component props.
+
+If you need the input props in your root component, use the [`getInputProps()`](/docs/get-input-props) function to retrieve input props.
+
+## You can still use components normally
+
+Even if a component is registered as a composition, you can still use it like a regular React component and pass the props directly:
+
+```tsx twoslash
+// @include: example-MyComponent
+// ---cut---
+<MyComponent propOne="hi" propTwo={10} />
+```
+
+This is useful if you want to concatenate multiple scenes together. You can use a [`<Series>`](/docs/series) to play two components after each other:
+
+```tsx twoslash title="ChainedScenes.tsx"
+// @include: example-MyComponent
+const AnotherComponent: React.FC = () => {
+ return null;
+};
+// ---cut---
+import { Series } from "remotion";
+
+const ChainedScenes = () => {
+ return (
+ <Series>
+ <Series.Sequence durationInFrames={90}>
+ <MyComponent propOne="hi" propTwo={10} />
+ </Series.Sequence>
+ <Series.Sequence durationInFrames={90}>
+ <AnotherComponent />
+ </Series.Sequence>
+ </Series>
+ );
+};
+```
+
+You may then register this "Master" component as an additional [`<Composition>`](/docs/the-fundamentals#compositions).
+
+## See also
+
+- [Avoid huge payloads for `defaultProps`](/docs/troubleshooting/defaultprops-too-big)
diff --git a/packages/docs/sidebars.js b/packages/docs/sidebars.js
index d7c62e921d..0c5e846576 100644
--- a/packages/docs/sidebars.js
+++ b/packages/docs/sidebars.js
@@ -381,8 +381,12 @@ module.exports = {
{
type: "category",
label: "Parametrized videos",
+ link: {
+ type: "doc",
+ id: "parametrized-rendering",
+ },
items: [
- "parametrized-rendering",
+ "passing-props",
"schemas",
"visual-editing",
"data-fetching",