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. 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 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.
newId
The new ID, containing only letters, numbers, or hyphens. It must be unused in this file.
metadata?
Overrides for width, height, fps, and durationInFrames. Omitted values are copied from the original.
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.
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 | ||||