Skip to main content

reorderNode()v4.0.530

Moves a node before or after a sibling.

warning

Draft API: This API is experimental and may change.

reorder-node.ts
import {reorderNode, type CodemodProject, type NodeReference} from '@remotion/codemods'; declare const project: CodemodProject; declare const node: NodeReference; declare const target: NodeReference; const result = await reorderNode({ project, node, target, position: 'before', }); console.log(result);

Both nodes must be direct siblings in the same file. This changes source order and stacking order, not timeline timing. Moving into a different parent or file is unsupported.

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.

target​

The sibling node reference to position relative to.

position​

Either before or after.

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.

updatedNode​

The moved node's reference in the new project.

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​