How to
Clone Figma Layer Node

How to clone/copy a Figma layer node

code.js
// first select the node by nodeId
const layerNode = figma.getNodeById(nodeId);
 
// prevent a figma memory leak (if not found, can't be cloned)
if (layerNode !== null) {
  // clone selected page
  const clone = layerNode.clone();
}