Skip to content

🎥 Make videos programmatically with React

Skills: Keep composition registrations editable

JonnyBurger11f8a3f248e0
diff --git a/packages/skills/skills/remotion-create/SKILL.md b/packages/skills/skills/remotion-create/SKILL.md
index aaae0eec1c..2ab5095dc9 100644
--- a/packages/skills/skills/remotion-create/SKILL.md
+++ b/packages/skills/skills/remotion-create/SKILL.md
@@ -43,6 +43,9 @@ npm i
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.
+Before writing the root that registers `<Composition>` or `<Still>` elements,
+follow [Compositions and stills](../remotion-markup/compositions.md).
+
## Is this a timeline of clips?
If the video arranges multiple video or audio clips on a timeline, follow
diff --git a/packages/skills/skills/remotion-interactivity/SKILL.md b/packages/skills/skills/remotion-interactivity/SKILL.md
index b3b35e9e85..3953344edf 100644
--- a/packages/skills/skills/remotion-interactivity/SKILL.md
+++ b/packages/skills/skills/remotion-interactivity/SKILL.md
@@ -18,10 +18,11 @@ If the markup is too complex for the Studio to make it interactive, then the val
The Studio edits the JSX source node that created an item. If multiple runtime
items come from the same JSX node, they share one source-editing target.
-For every clip, scene, layer or sequence that should be editable on its own,
-write a separate JSX node and keep its editable props on that node. This applies
-to built-in media components, `<Sequence>`, `<Series.Sequence>`,
-`<TransitionSeries.Sequence>` and custom components.
+For every composition registration, clip, scene, layer or sequence that should
+be editable on its own, write a separate JSX node and keep its editable props
+on that node. This applies to `<Composition>`, `<Still>`, built-in media
+components, `<Sequence>`, `<Series.Sequence>`, `<TransitionSeries.Sequence>`
+and custom components.
For example, author an editable timeline like this:
@@ -36,11 +37,12 @@ For example, author an editable timeline like this:
</Series>
```
-A `.map()` or another programmatic loop would create both runtime sequences
+A `.map()` or another programmatic loop would create multiple runtime items
from one JSX source node. That is appropriate for repeated output that is
intentionally controlled as one template, such as visualization bars or
-particles. It is not appropriate when the instances need independent names,
-timing, ordering, deletion or duplication in the Studio.
+particles. It is not appropriate when the instances need independent IDs or
+names, props, metadata, timing, ordering, deletion or duplication in the
+Studio.
## Make an HTML element interactive using `Interactive`
@@ -249,7 +251,7 @@ If possible, use `scale`, `rotate` and `translate` instead because only they are
## Keep composition metadata inline
-When scaffolding a composition, keep `width`, `height`, `fps`, `durationInFrames` and `defaultProps` inline and make no type assertions.
+When scaffolding a composition, use a JSX string literal for `id`, keep `width`, `height`, `fps`, `durationInFrames` and `defaultProps` inline and make no type assertions.
The Props editor can save visual edits back to your code when `defaultProps` is an inline object literal on `<Composition>` or `<Still>`.
diff --git a/packages/skills/skills/remotion-markup/SKILL.md b/packages/skills/skills/remotion-markup/SKILL.md
index 5c73e5a98f..013f2cf825 100644
--- a/packages/skills/skills/remotion-markup/SKILL.md
+++ b/packages/skills/skills/remotion-markup/SKILL.md
@@ -23,11 +23,12 @@ Use `Easing.bezier()` and `Easing.spring()` to customize timing.
Structure your markup according to [Remotion Interactivity Best Practices](../remotion-interactivity/SKILL.md)
-The Studio edits the JSX source node that created an item. Author every clip,
-scene, layer and sequence that should be editable independently as its own JSX
-node, with its editable props inline. Programmatic loops are suitable when the
-generated instances are intentionally controlled as one source template, not
-when users need to edit the instances separately.
+The Studio edits the JSX source node that created an item. Author every
+composition registration, clip, scene, layer and sequence that should be
+editable independently as its own JSX node, with its editable props inline.
+Programmatic loops are suitable when the generated instances are intentionally
+controlled as one source template, not when users need to edit the instances
+separately.
```tsx
import { useCurrentFrame, Easing, interpolate, Interactive } from "remotion";
@@ -365,9 +366,9 @@ When needing to detect and trim silent segments from video or audio files, load
See [calculate-metadata.md](calculate-metadata.md) for dynamically set composition duration, dimensions, and props.
-## Advanced compositions
+## Compositions and stills
-See [compositions.md](compositions.md) for how to define stills, folders, default props and for how to nest compositions. For Studio navigation into a scene's own timeline, use [connected compositions](connected-compositions.md).
+Before registering `<Composition>` or `<Still>` elements, read [compositions.md](compositions.md) for source-editable registrations, folders, default props and nesting. For Studio navigation into a scene's own timeline, use [connected compositions](connected-compositions.md).
## Advanced sequencing
diff --git a/packages/skills/skills/remotion-markup/compositions.md b/packages/skills/skills/remotion-markup/compositions.md
index 1a46404750..4320f93782 100644
--- a/packages/skills/skills/remotion-markup/compositions.md
+++ b/packages/skills/skills/remotion-markup/compositions.md
@@ -7,6 +7,52 @@ metadata:
A `<Composition>` defines the component, width, height, fps and duration of a renderable video.
+## Source-editable registrations
+
+Give each composition or still that should be edited independently in the
+Studio its own authored JSX node. Use a JSX string literal for `id`, and keep
+its metadata and editable default values directly on that node.
+
+Programmatic registration is suitable when the generated compositions are
+intentionally controlled as one source template and do not need to be
+reordered, duplicated, deleted or edited individually in the Studio.
+
+```tsx
+type Props = {
+ readonly title: string;
+};
+
+export const MyComposition = ({title}: Props) => <h1>{title}</h1>;
+
+export const RemotionRoot = () => {
+ return (
+ <>
+ <Composition
+ id="Launch"
+ component={MyComposition}
+ durationInFrames={180}
+ fps={30}
+ width={1920}
+ height={1080}
+ defaultProps={{title: 'Launch'}}
+ />
+ <Composition
+ id="Recap"
+ component={MyComposition}
+ durationInFrames={240}
+ fps={30}
+ width={1920}
+ height={1080}
+ defaultProps={{title: 'Recap'}}
+ />
+ </>
+ );
+};
+```
+
+Both registrations can reuse the same component. Keeping them as separate JSX
+nodes gives each one its own source-editing target.
+
## Default Props and scaffold metadata
Pass `defaultProps` to provide initial values for your component.
@@ -14,6 +60,7 @@ Values must be JSON-serializable (`Date`, `Map`, `Set`, and `staticFile()` are s
Use `defaultProps` for composition-wide values that should be visible and editable before the video renders.
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`.
When scaffolding, keep the component and `<Composition>` registration in the same file so `width`, `height`, `fps`, `durationInFrames`, and `defaultProps` are visible next to the code that uses them.
Use `type` declarations for props rather than `interface` to ensure `defaultProps` type safety.