Skip to main content
Question

Developing a Plugin for Automating Design Fetch and Recreation from a Single-Component Figma File

  • January 5, 2024
  • 1 reply
  • 312 views

Hi, I’m wondering whether it would be possible to create a plugin that fetches a component from a Figma file (based on a link I provide), which has one component, and recreates it when I run my plugin?

This topic has been closed for comments

1 reply

Lucas_Miqueias

Yes, it’s possible.

I do this by getting the key file in URL.
example:
URL = https://www.figma.com/file/<key>/name?type=design&t=xyz

I use REST API for get components list

curl -H 'X-FIGMA-TOKEN: xxx' 'https://api.figma.com/v1/files/<key>/components'

And then take key component for import using importComponentByKeyAsync
example:

const importComponent = await figma.importComponentByKeyAsync(key);
const instance = importComponent.createInstance();
const page = figma.currentPage;

page.appendChild(instance);

Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings