packages/docs/docs/get-input-props.mdx
Using this method, you can retrieve inputs that you pass in from the command line using --props, or the inputProps parameter if you are using the Node.JS APIs (renderMedia(), renderMediaOnLambda()).
This method is useful if you want to retrieve the input props in the root component.
This method is not available when inside a <Player> or when client-side rendering. Instead, get the props as React props from the component you passed as the component prop to the player.
Prefer the following ways of getting your input props:
calculateMetadata() function.In both cases, you can type the props, which is better than using this API which returns a non-typesafe object.
Pass in a parseable JSON representation using the --props flag to either remotion studio or remotion render:
npx remotion render --props='{"hello": "world"}'
To simulate how it behaves, you can also pass props when using the Remotion Studio:
npx remotion studio --props='{"hello": "world"}'
You may also specify a file containing JSON and Remotion will parse the file for you:
npx remotion render --props=./path/to/props.json
You can then access the props anywhere in your Remotion project:
import {Composition} from 'remotion';
const getInputProps = () => ({hello: 'world'}) as const;
const MyComp: React.FC = () => null;
const config = {
component: MyComp,
durationInFrames: 100,
fps: 30,
width: 1000,
height: 1000,
id: 'MyComp',
} as const;
// ---cut---
export const Root: React.FC = () => {
const {hello} = getInputProps(); // "world"
return <Composition {...config} />;
};
In this example, the props also get passed to the component of the composition with the id my-composition.
<CompatibilityTable chrome firefox safari nodejs={'No-op, returns {}'} bun={'No-op, returns {}'} serverlessFunctions={'No-op, returns {}'} clientSideRendering={'No-op, returns {}'} serverSideRendering player={'No-op, returns {}'} studio />