Skip to main content

addEffect()v4.0.528

Appends an effect to a node's inline effects array and adds its import.

warning

Draft API: This API is experimental and may change.

add-effect.ts
import {addEffect, type CodemodProject, type NodeReference} from '@remotion/codemods'; declare const project: CodemodProject; declare const node: NodeReference; const result = await addEffect({ project, node, importName: 'blur', importPath: '@remotion/effects/blur', props: {radius: 8}, }); console.log(result);

Creates the effects attribute if missing. The component must support effects at runtime. Computed effects arrays and potentially overriding spreads are rejected; packages are not installed.

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.

importName​

The effect's named export, such as blur.

importPath​

The effect module. Supports @remotion/effects/*, @remotion/light-leaks, and @remotion/starburst.

props?​

Serializable effect configuration. Defaults to {}.

Return value​

A promise resolving to 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.

insertedEffect​

The new effect reference, including its zero-based effectIndex.

Errors​

Throws or rejects 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​