Skip to main content

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?

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);

Reply