addEffect()v4.0.528
Appends an effect to a node's inline effects array and adds its import.
Draft API: This API is experimental and may change.
add-effect.tsimport {addEffect , typeCodemodProject , typeNodeReference } from '@remotion/codemods'; declare constproject :CodemodProject ; declare constnode :NodeReference ; constresult =addEffect ({project ,node ,importName : 'blur',importPath : '@remotion/effects/blur',props : {radius : 8},wrapInHtmlInCanvas : null, });console .log (result );
Creates the effects attribute if missing. The component receiving the effect must support effects at runtime. Throws for computed effects arrays and spreads that can override the effects attribute. Install effect packages separately.
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.
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 {}.
wrapInHtmlInCanvasv4.0.546
Pass null to apply the effect directly to the node. Pass the props below to wrap the node in <HtmlInCanvas> and apply the effect to the wrapper in one edit. The wrapper inherits the node’s explicit width and height props. See wrapNode() for dimension and positioning rules.
measuredSize
Fallback dimensions for a layer without explicit width and height props. Use null to require explicit dimensions in the source. See wrapNode() for the object shape.
from
The wrapper start frame relative to its parent.
durationInFrames
The duration of the wrapper in frames.
trimBefore
The number of frames to trim from the start of the wrapper.
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.
insertedEffect
The new effect reference, including its zero-based effectIndex.
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 | ||||