duplicateComposition()v4.0.528
Copies a composition or still registration with a new ID.
Draft API: This API is experimental and may change.
duplicate-composition.tsimport {duplicateComposition , typeCodemodProject } from '@remotion/codemods'; declare constproject :CodemodProject ; constresult =duplicateComposition ({project ,compositionFile : 'src/Root.tsx',compositionId : 'MyComposition',newId : 'Portrait',metadata : {width : 1080,height : 1920}, });console .log (result );
Both registrations reference the same component implementation. Default props and other registration props are copied. By default, the original registration kind is preserved: a <Still> remains a <Still>.
<Still> registrations only support width and height overrides; supplying FPS or duration throws an error.
Options
project
An in-memory CodemodProject. The input project is not mutated.
compositionFile
The project file containing the <Composition> or <Still> registration. Static IDs, named import aliases, and namespace imports from remotion are supported.
compositionId
The static ID of the composition to edit.
newId
The new ID, containing only ASCII letters, numbers, CJK characters, or hyphens. It must be unused in this file.
metadata?
Overrides for width, height, fps, and durationInFrames. Omitted values are copied from the original.
tag?
'Composition' or 'Still'. Defaults to the original registration kind. Choosing 'Still' removes fps and durationInFrames from the copy. When converting a still to a composition, provide these values through metadata.
Return value
Returns an object with the following properties.
changes
An array of {filePath, previousContents, nextContents} file changes. A null content value indicates a created or deleted file.
nodePathRemappingsv4.0.530
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.
insertedNodev4.0.530
The reference of the inserted copy in the new project.
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
| Browsers | Servers | Environments | |||||||
|---|---|---|---|---|---|---|---|---|---|
Chrome | Firefox | Safari | Node.js | Bun | Serverless Functions | ||||