Back to Remotion

saveDefaultProps()

packages/docs/docs/studio/save-default-props.mdx

4.0.4652.2 KB
Original Source

saveDefaultProps()<AvailableFrom v="4.0.147"/>

Saves the defaultProps for a composition back to the root file. updateDefaultProps() is an alias for this function.

Examples

tsx
// @target: esnext
import { saveDefaultProps } from "@remotion/studio";

await saveDefaultProps({
  compositionId: "my-composition",
  defaultProps: () => {
    return {
      color: "green",
    };
  },
});

You can access the saved default props to only override part of it (reducer-style):

tsx
// @target: esnext
import { saveDefaultProps } from "@remotion/studio";

await saveDefaultProps({
  compositionId: "my-composition",
  defaultProps: ({ savedDefaultProps }) => {
    return {
      ...savedDefaultProps,
      color: "green",
    };
  },
});

If you have a Zod schema, you can also access its runtime value:

tsx
// @target: esnext
import { saveDefaultProps } from "@remotion/studio";

await saveDefaultProps({
  compositionId: "my-composition",
  defaultProps: ({ schema, savedDefaultProps }) => {
    // Do something with the Zod schema

    return {
      ...savedDefaultProps,
      color: "red",
    };
  },
});

unsavedDefaultProps

:::info Before v4.0.437, the Props Editor had a concept of "unsaved props" that were not yet written back to the root file. Starting from v4.0.437, all prop changes are immediately saved, so unsavedDefaultProps is now always the same as savedDefaultProps.

It is still accepted for backwards compatibility, but you should use savedDefaultProps instead. :::

Requirements

In order to use this function:

<Step>1</Step> You need to be inside the Remotion Studio.

<Step>2</Step> The Studio must be running (no static deployment)

<Step>3</Step> <code>zod</code> needs to be installed.

Otherwise, the function will throw.

See also