Defining a schema for your props
Use Zod to validate the props your component accepts and to customize their controls in the Remotion Studio.
You do not need to define a schema to edit props visually. Since v4.0.516, Remotion infers basic controls from defaultProps. See When to define a schema for cases where an explicit schema is useful.
AI agent prompt
Use this prompt to make an existing composition parameterizable:
Make this Remotion composition parameterizable in Remotion Studio.
Find the component that is passed to <Composition> and the file where the composition is registered.
Define a TypeScript type that describes the props the component accepts.
Add defaultProps to the <Composition> that match the type and preserve the current rendered output.
Keep defaultProps as an inline object literal so Remotion can infer visual controls and save changes back to the file.
If zod is missing, install it with npx remotion add zod.
Only add a Zod schema when the props need validation, constraints, choices, descriptions or specialized controls.
Keep the existing composition behavior unchanged except for making the props editable in Remotion Studio.Prerequisites
To define a schema, install zod:
npx remotion add zodInstall @remotion/zod-types as well if you want to use Remotion-specific types such as zColor(), zTextarea() or zMatrix().
Defining a schema
To define a schema for your props, use z.object():
import {z } from 'zod';
export const myCompSchema = z .object ({
propOne : z .string (),
propTwo : z .string (),
});Using z.infer(), you can turn the schema into a type:
export const MyComp : React .FC <z .infer <typeof myCompSchema >> = ({propOne , propTwo }) => {
return (
<div >
props: {propOne }, {propTwo }
</div >
);
};Adding a schema to your composition
Use the schema prop to attach the schema to your <Composition>. Remotion will require you to specify matching defaultProps.
src/Root.tsximportReact from 'react'; import {Composition } from 'remotion'; import {MyComponent ,myCompSchema } from './MyComponent'; export constRemotionRoot :React .FC = () => { return ( <Composition id ="my-video"component ={MyComponent }durationInFrames ={100}fps ={30}width ={1920}height ={1080}schema ={myCompSchema }defaultProps ={{propOne : 'Hello World',propTwo : 'Welcome to Remotion', }} /> ); };
Editing props visually
The schema determines which controls appear when you edit props visually in the Remotion Studio. It overrides the controls that Remotion would otherwise infer from defaultProps.
Validation during renderingv4.0.544
The Remotion Studio uses the schema to mark invalid props, and does not apply them.
When you render with the CLI, the server-side rendering APIs or Lambda, Remotion validates the input props, merged with the default props, against the schema before it calls calculateMetadata().
If the props are invalid, Remotion 4.0 logs a warning that lists each invalid field, and renders with the props anyway. In Remotion 5.0, the render fails with an error instead. See the v5.0 migration guide.
Remotion merges input props shallowly with the default props. A top-level key in the input props replaces the whole value of that key in the default props, including nested objects.
Supported types
All schemas that are supported by Zod can be used to validate props. The visual props editor only provides controls for some of them; see Supported controls for the list. Other types are displayed as not editable.
Remotion requires that the top-level type is a z.object(), because the collection of props of a React component is always an object.
In addition to the built in types, the @remotion/zod-types package also provides types like zColor(), zTextarea() and zMatrix().