Skip to main content

updateNodeKeyframes()v4.0.530

Adds, removes, moves, or configures keyframes on a node prop.

warning

Draft API: This API is experimental and may change.

update-node-keyframes.ts
import {updateNodeKeyframes, type CodemodProject, type NodeReference} from '@remotion/codemods'; declare const project: CodemodProject; declare const node: NodeReference; const result = updateNodeKeyframes({ project, node, updates: [ {key: 'style.opacity', operation: {type: 'add', frame: 0, value: 0}}, {key: 'style.opacity', operation: {type: 'add', frame: 30, value: 1}}, ], }); console.log(result);

Adds the required interpolation imports and frame hook. Supports recognized inline interpolation expressions; unsupported dynamic expressions throw. Frame coordinates belong to the interpolation expression's local frame clock.

Creating an animation that needs a new useCurrentFrame() hook requires an enclosing function. Existing supported interpolation expressions can be edited outside functions. Static prop edits outside functions remain supported by updateNodeProps().

From v4.0.544, this function returns its result synchronously and throws errors immediately.

Options​

project​

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

node​

A NodeReference from getNodes() or a previous operation. It contains filePath and nodePath.

updates​

An array of {key, operation} objects, applied in order. Node prop keys may use paths such as style.opacity. Effect keys name configuration properties.

operation​

Use {type: 'add', frame, value} to add or replace a keyframe; {type: 'remove', frame, valueWhenLastKeyframeDeleted} to remove one; {type: 'move', moves: [{fromFrame, toFrame}]} to move keyframes; {type: 'easing', segmentIndex, easing} to change easing; or {type: 'settings', clamping, posterize, output} to change interpolation settings. For settings, pass undefined for unchanged fields. valueWhenLastKeyframeDeleted supplies the static fallback when removing the final keyframe, or null to use the supported default.

schema?​

A Remotion InteractivitySchema for schema-specific defaults and enum variants. By default, no schema-specific behavior is applied.

videoConfig?​

The composition's width, height, fps, and durationInFrames. Supply these to interpret supported expressions using useVideoConfig(). By default, those runtime values are unknown.

prettierConfigOverride?​

Formatting options for generated source. Defaults to null, which follows the existing source style.

Return value​

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.

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 edited node reference. Adding a frame hook can change node paths throughout the component.

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​