How to use installed components in a Figma plugin?

Hey everyone! I’m working on a Figma plugin and I’m stuck. I want to use components that are installed but not yet used in the current document. For example, let’s say I have this cool alert component in my assets. How can I make my plugin create it in the document even if it’s not been used before? I’ve looked through the docs but can’t find anything about accessing the asset panel components. Is this even possible? If anyone has experience with this or knows a workaround, I’d really appreciate some help! Thanks in advance!

hey mikechen, had the same issue. afaik you cant access installed components directly thru the plugin API :frowning: best workaround i found is to create a ‘library’ page in your doc with all the components you wanna use. then ur plugin can grab em from there. not ideal but works

As someone who’s developed a few Figma plugins, I can confirm that accessing installed components not used in the document is indeed tricky. The API doesn’t provide direct access to the asset panel, which is a limitation many developers face.

One approach I’ve used successfully is creating a separate Figma file as a ‘component library’. In this file, I place all the components I want to use in my plugin. Then, I use the Figma API to fetch components from this file using its file key.

Here’s a rough outline of the process:
Create a separate ‘library’ file with your components
Get the file key (found in the file’s URL)
In your plugin, use the API to fetch components from this file
Create instances of these components in the current document

It’s not as seamless as accessing the asset panel directly, but it’s a workable solution that gives you more control over which components are available to your plugin.