z
z
is a re-export of the Zod library (version 3.21.4
).
You may use it to define schemas for compositions in order to make the input props type-safe.
Example
The following usage is recommended, since it will make defaultProps
type-safe and them editable in the schema editor in the Remotion Preview:
MyComp.tsxtsx
import {z } from "remotion";export constmyCompSchema =z .object ({title :z .string (),subtitle :z .string (),});export constMyComp :React .FC <z .infer <typeofmyCompSchema >> = ({title ,subtitle ,}) => {return (<div ><h1 >{title }</h1 ><h2 >{subtitle }</h2 ></div >);};
MyComp.tsxtsx
import {z } from "remotion";export constmyCompSchema =z .object ({title :z .string (),subtitle :z .string (),});export constMyComp :React .FC <z .infer <typeofmyCompSchema >> = ({title ,subtitle ,}) => {return (<div ><h1 >{title }</h1 ><h2 >{subtitle }</h2 ></div >);};
Root.tsxtsx
importReact from "react";import {Composition } from "remotion";import {MyComp ,myCompSchema } from "./MyComp";export constRemotionRoot :React .FC = () => {return (<Composition id ="my-comp"component ={MyComp }durationInFrames ={100}fps ={30}width ={1920}height ={1080}schema ={myCompSchema }defaultProps ={{title : "Hello World",subtitle : "Welcome to Remotion",}}/>);};
Root.tsxtsx
importReact from "react";import {Composition } from "remotion";import {MyComp ,myCompSchema } from "./MyComp";export constRemotionRoot :React .FC = () => {return (<Composition id ="my-comp"component ={MyComp }durationInFrames ={100}fps ={30}width ={1920}height ={1080}schema ={myCompSchema }defaultProps ={{title : "Hello World",subtitle : "Welcome to Remotion",}}/>);};