Skip to main content

updateNodeProps()v4.0.530

Updates node props, nested object properties, and supported text children.

warning

Draft API: This API is experimental and may change.

update-node-props.ts
import {updateNodeProps, type CodemodProject, type NodeReference} from '@remotion/codemods'; declare const project: CodemodProject; declare const node: NodeReference; const result = updateNodeProps({ project, node, props: {'style.opacity': 0.5, title: 'Preview'}, }); console.log(result);

The props form rejects computed props, including props potentially overridden by a spread. Setting a keyframed prop replaces the animation with the supplied static value; use updateNodeKeyframes() to edit its animation. Unchanged surrounding source is preserved.

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.

props?​

A non-empty record of new values, such as {from: 30, 'style.opacity': 0.5}. A value of undefined removes the prop or nested property. Only one level of nested keys is supported. Use children to replace static text. Use staticFileValue() to write a staticFile() call. Provide exactly one of props or updates.

updates?​

A non-empty array of explicit prop edits. Use this form to remove a value when it matches a known default or to paste a structured animation. Unlike props, this form permits replacing computed prop values.

key​

The prop name, children, or a one-level nested path such as style.opacity.

value​

The new value. Set to undefined with defaultValue: null to remove the prop.

defaultValue​

The component's default value, or null when no default is known. An explicit prop is removed when its new value equals a non-null default.

googleFont?​

A Google Font selection with fontFamily, importName, style, weights, and subsets. Adds the font import and loading code needed for the selected font. Defaults to no font source edit.

clipboardParam?​

A structured static or keyframed parameter to paste. When supplied, its expression is used instead of value, and the required animation imports are added. Defaults to no pasted parameter.

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​

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.

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's reference in the new project.

oldValueStrings​

The previous source values in update order, for displaying the changes.

removedProps​

An array of {key, valueString} entries for additional props removed when a schema enum changes variants.

logLine​

The one-based line of the node's opening tag in the input source.

newNodePath​

The edited node's path in the updated source.

formatted​

true when the edit succeeds. Generated source follows the selected formatting options.

results​

A one-element array containing oldValueStrings, removedProps, logLine, and newNodePath. This matches the per-node results returned by updateMultipleNodeProps().

updatedNodes​

A one-element array containing updatedNode.

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​