How do I createPage below currentPage?

Hi, I’m trying to createPage below the currentPage. Is there a way to do so instead of always creating page at the bottom of the list? Thanks!

Use the insertChild() method on root.

For example, like this:

let page = figma.createPage(),
    index = figma.root.children.findIndex(el => === + 1;
figma.root.insertChild(index, page);

I did it like this
figma.root.insertChild(figma.root.children.indexOf(figma.currentPage) + 1, page);

1 Like