Skip to content

🎥 Make videos programmatically with React

Docs: Remove composition placement commentary

Jonny Burger747e9a2b7374
diff --git a/.agents/skills/import-canvas-capture/SKILL.md b/.agents/skills/import-canvas-capture/SKILL.md
index d35c7194c4..9960b85421 100644
--- a/.agents/skills/import-canvas-capture/SKILL.md
+++ b/.agents/skills/import-canvas-capture/SKILL.md
@@ -14,8 +14,7 @@ not distribute it through `packages/skills` or document the command as a stable
recording must contain embedded `REMOTION_CAPTURE_DATA` metadata; a converted
video that has lost this metadata cannot be imported.
2. Inspect the project to find the TypeScript file containing its composition
- registrations (usually `src/Root.tsx`). Keep all registrations directly in
- that root file. Choose an unused composition ID.
+ registrations (usually `src/Root.tsx`). Choose an unused composition ID.
3. From the target project's root, run:
```sh
@@ -34,9 +33,8 @@ not distribute it through `packages/skills` or document the command as a stable
```
4. Review the reported source files and public asset. The importer generates a
- video component beside the root file, inserts its `<Composition>` registration
- directly into the root, copies the video to the public directory, and installs
- missing `@remotion/media` and
+ component beside the registration file, registers it, copies the video to the
+ public directory, and installs missing `@remotion/media` and
`@remotion/mac-cursors` dependencies at the project's Remotion version. Studio
does not need to be running. Existing Studio sessions pick up source changes
through their file watchers; this operation does not enter Studio's undo stack.
diff --git a/packages/docs/docs/codemods/add-canvas-capture-composition.mdx b/packages/docs/docs/codemods/add-canvas-capture-composition.mdx
index e31621def8..689a1def2e 100644
--- a/packages/docs/docs/codemods/add-canvas-capture-composition.mdx
+++ b/packages/docs/docs/codemods/add-canvas-capture-composition.mdx
@@ -6,7 +6,7 @@ crumb: '@remotion/codemods'
# addCanvasCaptureComposition()<AvailableFrom v="4.0.528" />
-Creates an interactive Canvas Capture component and inserts a [`<Composition>`](/docs/composition) registration directly into `src/Root.tsx`. Both files are returned in one result. Use [`addComposition()`](/docs/codemods/add-composition) when the component implementation already exists.
+Creates an interactive Canvas Capture component and registers it in the project. Both files are returned in one result. Use [`addComposition()`](/docs/codemods/add-composition) when the component implementation already exists.
:::warning
@@ -53,7 +53,7 @@ An in-memory [`CodemodProject`](/docs/codemods#project-model). The input project
### compositionFile
-The existing root file containing the composition registrations, normally `src/Root.tsx`. The same [registration-root requirements and import support](/docs/codemods/add-composition#compositionfile) as [`addComposition()`](/docs/codemods/add-composition) apply.
+The existing project file containing the registration component. The same [registration-root requirements and import support](/docs/codemods/add-composition#compositionfile) as [`addComposition()`](/docs/codemods/add-composition) apply.
### compositionId
diff --git a/packages/docs/docs/codemods/add-composition.mdx b/packages/docs/docs/codemods/add-composition.mdx
index 8b6129eda3..58febc380d 100644
--- a/packages/docs/docs/codemods/add-composition.mdx
+++ b/packages/docs/docs/codemods/add-composition.mdx
@@ -40,7 +40,7 @@ An in-memory [`CodemodProject`](/docs/codemods#project-model). The input project
### compositionFile
-The root file containing the composition registrations, normally `src/Root.tsx`. Keep all registrations directly in this file. Registration edits support [`<Composition>`](/docs/composition), [`<Still>`](/docs/still), and [`<Folder>`](/docs/folder) with static IDs or folder names. Aliased and namespace imports from `remotion` are supported.
+The project file containing the composition registrations. Registration edits support [`<Composition>`](/docs/composition), [`<Still>`](/docs/still), and [`<Folder>`](/docs/folder) with static IDs or folder names. Aliased and namespace imports from `remotion` are supported.
When `folder` is omitted, the file must have one component containing registrations, or a single component if no registrations exist yet. The first JSX return in the selected component is used; returns in nested functions are ignored.
diff --git a/packages/docs/docs/composition.mdx b/packages/docs/docs/composition.mdx
index 9720d46f19..c60fd0979a 100644
--- a/packages/docs/docs/composition.mdx
+++ b/packages/docs/docs/composition.mdx
@@ -27,7 +27,7 @@ export const RemotionRoot: React.FC = () => {
## API
-A `<Composition />` should be placed in the root component, which is registered using [`registerRoot()`](/docs/register-root).
+A `<Composition />` should be placed within a fragment of the root component (which is registered using [`registerRoot()`](/docs/register-root)).
The component takes the following props:
diff --git a/packages/docs/docs/folder.mdx b/packages/docs/docs/folder.mdx
index 999df3ed9e..4cf42e3f7d 100644
--- a/packages/docs/docs/folder.mdx
+++ b/packages/docs/docs/folder.mdx
@@ -9,8 +9,6 @@ crumb: 'API'
By wrapping a [`<Composition />`](/docs/composition) inside a `<Folder />`, you can visually categorize it in your sidebar, should you have many compositions.
-Keep folders and their composition registrations directly in `src/Root.tsx`.
-
## Example
```tsx twoslash title="src/Root.tsx"
diff --git a/packages/docs/docs/player/player-integration.mdx b/packages/docs/docs/player/player-integration.mdx
index d72e55a1b9..89bbeffbc5 100644
--- a/packages/docs/docs/player/player-integration.mdx
+++ b/packages/docs/docs/player/player-integration.mdx
@@ -90,7 +90,7 @@ export const MyComp: React.FC<{text: string}> = ({text}) => {
};
```
-Keep all composition registrations directly in your root file (`src/remotion/Root.tsx` in this example):
+Your list of videos (`remotion/Root.tsx` in the example) could look like this:
```tsx twoslash title="src/remotion/Root.tsx"
// @allowUmdGlobalAccess
diff --git a/packages/docs/docs/register-root.mdx b/packages/docs/docs/register-root.mdx
index 500c62bf9a..6daef7898c 100644
--- a/packages/docs/docs/register-root.mdx
+++ b/packages/docs/docs/register-root.mdx
@@ -5,7 +5,7 @@ title: registerRoot()
crumb: 'API'
---
-`registerRoot` is a function that registers the root component of the Remotion project. Define all composition registrations directly in the root component in `src/Root.tsx`. Wrap multiple registrations in a React Fragment.
+`registerRoot` is a function that registers the root component of the Remotion project. In the root component, one or multiple compositions should be returned (in the case of multiple compositions, they should be wrapped in a React Fragment).
:::info
`registerRoot()` should live in a file that is separate from the list of compositions. This is because when using React Fast Refresh, all the code in the file that gets refreshed gets executed again, however, this function should only be called once.
diff --git a/packages/docs/docs/still.mdx b/packages/docs/docs/still.mdx
index 7e20922034..f3654781df 100644
--- a/packages/docs/docs/still.mdx
+++ b/packages/docs/docs/still.mdx
@@ -7,8 +7,6 @@ crumb: 'API'
A `<Still />` is a single-frame [`<Composition />`](/docs/composition). It is a convenient way to define a composition that renders an image rather than a video.
-Define still registrations directly in `src/Root.tsx`, alongside your video compositions.
-
## Example
The `<Still />` component has the same API as the [`<Composition />`](/docs/composition) component, except that it's not necessary to pass `durationInFrames` and `fps`.
diff --git a/packages/docs/docs/terminology/root-file.mdx b/packages/docs/docs/terminology/root-file.mdx
index 4130e2dc94..1121a713a2 100644
--- a/packages/docs/docs/terminology/root-file.mdx
+++ b/packages/docs/docs/terminology/root-file.mdx
@@ -5,9 +5,7 @@ crumb: "Terminology"
---
The Root file is the file that exports the Root component, which renders one or more [`<Composition />`](/docs/composition) components.
-By default, it is `src/Root.tsx`. Some templates use `remotion/Root.tsx`.
-
-Keep all [`<Composition>`](/docs/composition), [`<Still>`](/docs/still), and [`<Folder>`](/docs/folder) registrations directly in this file. Import the components that render your videos and images from their own files.
+By default, it is `src/Root.tsx` or `remotion/Root.tsx` in most Remotion templates, but you may reorganize the files arbitrarily.
The [entry point](/docs/terminology/entry-point) will import the Root file and register it with [`registerRoot()`](/docs/register-root)
diff --git a/packages/docs/docs/the-fundamentals.mdx b/packages/docs/docs/the-fundamentals.mdx
index a2ef49197d..c1e694d84d 100644
--- a/packages/docs/docs/the-fundamentals.mdx
+++ b/packages/docs/docs/the-fundamentals.mdx
@@ -77,7 +77,7 @@ A video's first frame is `0` and its last frame is `durationInFrames - 1`.
A composition is the combination of a React component and video metadata.
-Define all [`<Composition>`](/docs/composition) registrations directly in `src/Root.tsx` to make your videos renderable and visible in the Remotion sidebar. Import the components that render the videos from their own files.
+By rendering a [`<Composition>`](/docs/composition) component in `src/Root.tsx`, you can register a renderable video and make it visible in the Remotion sidebar.
```tsx twoslash title="src/Root.tsx"
import {Composition} from 'remotion';
diff --git a/packages/skills/skills/remotion-captions/display-captions.md b/packages/skills/skills/remotion-captions/display-captions.md
index 4f1cbc4f68..6e6b7297be 100644
--- a/packages/skills/skills/remotion-captions/display-captions.md
+++ b/packages/skills/skills/remotion-captions/display-captions.md
@@ -145,8 +145,6 @@ export const MyComposition: React.FC = () => {
};
```
-Register the video directly in `src/Root.tsx`:
-
```tsx title="src/Root.tsx"
import { Composition } from "remotion";
import { MyComposition } from "./MyComposition";
diff --git a/packages/skills/skills/remotion-create/SKILL.md b/packages/skills/skills/remotion-create/SKILL.md
index 841265e29e..c294e2ba82 100644
--- a/packages/skills/skills/remotion-create/SKILL.md
+++ b/packages/skills/skills/remotion-create/SKILL.md
@@ -47,10 +47,8 @@ As soon as the project can run, open [Remotion Studio](../remotion-studio/SKILL.
Keep the scaffold and add React Markup.
Follow [Remotion React Markup Best Practices](../remotion-markup/SKILL.md) and [Video Layout Rules](video-layout.md) for video-first layout and text sizing guidance.
-Keep all `<Composition>`, `<Still>`, and `<Folder>` registrations directly in
-`src/Root.tsx`, and import the video components from their own files.
-Before writing the root, follow
-[Compositions and stills](../remotion-markup/compositions.md).
+Before writing the root that registers `<Composition>` or `<Still>` elements,
+follow [Compositions and stills](../remotion-markup/compositions.md).
## Is this a timeline of clips?
diff --git a/packages/skills/skills/remotion-markup/SKILL.md b/packages/skills/skills/remotion-markup/SKILL.md
index 4d45ded7da..e083842b64 100644
--- a/packages/skills/skills/remotion-markup/SKILL.md
+++ b/packages/skills/skills/remotion-markup/SKILL.md
@@ -15,10 +15,6 @@ If you detect a surprising change made in the meanwhile, don't overwrite it, ass
## General rules
-Keep all `<Composition>`, `<Still>`, and `<Folder>` registrations directly in
-`src/Root.tsx`. Import the video components from their own files and render
-the registrations in the root component's JSX.
-
Inside a composition or scene component, get `fps` from `useVideoConfig()` for
all seconds-to-frames calculations, including timing props such as `from`,
`trimBefore`, `durationInFrames`, and `premountFor`. Keeping the expression on
diff --git a/packages/skills/skills/remotion-markup/compositions.md b/packages/skills/skills/remotion-markup/compositions.md
index 476419cf82..e042330a43 100644
--- a/packages/skills/skills/remotion-markup/compositions.md
+++ b/packages/skills/skills/remotion-markup/compositions.md
@@ -7,11 +7,6 @@ metadata:
A `<Composition>` defines the component, width, height, fps and duration of a renderable video.
-Keep all `<Composition>`, `<Still>`, and `<Folder>` registrations directly in
-`src/Root.tsx`. Import the video and image components from their own files.
-Each registration should be an authored JSX node in the root component's
-return, optionally inside a `<Folder>` in the same file.
-
## Source-editable registrations
Give each composition or still that should be edited independently in the
@@ -77,7 +72,6 @@ prop. See [Displaying captions](../remotion-captions/display-captions.md).
For Studio editing, keep `defaultProps` as an inline object literal on `<Composition>` or `<Still>`.
Keep values that should be written back directly in the object instead of deriving them from a loop variable.
Do not store it in a variable, import it, spread it, create it with a helper, or wrap it in `satisfies`.
-Keep `width`, `height`, `fps`, `durationInFrames`, and `defaultProps` directly on each registration in `src/Root.tsx`.
Use `type` declarations for props rather than `interface` to ensure `defaultProps` type safety.
```tsx title="src/Root.tsx"
diff --git a/packages/skills/skills/remotion-markup/connected-compositions.md b/packages/skills/skills/remotion-markup/connected-compositions.md
index 9d9b1b47b2..9ddfe225be 100644
--- a/packages/skills/skills/remotion-markup/connected-compositions.md
+++ b/packages/skills/skills/remotion-markup/connected-compositions.md
@@ -11,7 +11,7 @@ Use connected composition when a section has its own layers or timing, will be r
Render the exported component directly in the parent with inline timing and editable props.
It does not need an additional `<Sequence>` to connect to its registration.
For consecutive scenes or transitions, render one direct instance as the only child of a `<Series.Sequence>` or `<TransitionSeries.Sequence>`.
-3. Register the **same component reference** with `<Composition component={...}>` directly in `src/Root.tsx`.
+3. Register the **same component reference** with `<Composition component={...}>` in the root.
Give it a unique `id` and the dimensions, fps, and natural duration needed to preview the scene on its own. A `<Folder>` can keep scene compositions together.
## Make the component independent of its parent
diff --git a/packages/skills/skills/remotion-markup/multi-scene-video.md b/packages/skills/skills/remotion-markup/multi-scene-video.md
index a7b1b54cf8..ac61314459 100644
--- a/packages/skills/skills/remotion-markup/multi-scene-video.md
+++ b/packages/skills/skills/remotion-markup/multi-scene-video.md
@@ -47,7 +47,7 @@ export const MyVideo = () => {
};
```
-Register the same scene components, plus the parent video, directly in `src/Root.tsx`:
+Register the same scene components, plus the parent video, in the root:
```tsx title="src/Root.tsx"
import {Composition, Folder} from 'remotion';