Skip to main content

setCompositionDefaultProps()v4.0.528

Replaces a composition's statically readable default props or adds them when missing.

warning

Draft API: This API is experimental and may change.

set-composition-default-props.ts
import {setCompositionDefaultProps, type CodemodProject} from '@remotion/codemods'; declare const project: CodemodProject; const result = setCompositionDefaultProps({ project, compositionFile: 'src/Root.tsx', compositionId: 'MyComposition', defaultProps: {title: 'Hello', backgroundColor: '#ffffff'}, }); console.log(result);

Computed default props and props potentially overridden by a spread are rejected. The component implementation is unchanged.

Options

project

An in-memory CodemodProject. The input project is not mutated.

compositionFile

The project file containing the composition registrations. Registration edits support <Composition>, <Still>, and <Folder> with their original import names and static IDs or folder names.

compositionId

The static ID of the composition to edit.

defaultProps

The complete replacement object of serializable prop values. This replaces the object rather than merging it.

Return value

Returns an object with the following properties.

project

The updated project. Unchanged files and extra project fields are preserved.

changes

An array of {filePath, previousContents, nextContents} file changes. A null content value indicates a created or deleted file.

nodePathRemappings

An array of {filePath, oldNodePath, newNodePath} mappings. A null old path indicates an insertion; a null new path indicates removal. Apply these mappings to references from the input project. See node references.

updatedNode

The composition registration's node reference.

Errors

Throws when the target cannot be resolved, the requested edit is unsupported, or an option is invalid. Failed edits leave the input project unchanged.

Compatibility

BrowsersServersEnvironments
Chrome
Firefox
Safari
Node.js
Bun
Serverless Functions

See also