I’m working on a Figma plugin and need help with component access. Can I get components that are available in the assets panel but haven’t been used in the current document yet?
Let me give you an example. I have a notification banner component sitting in my assets library. My plugin needs to create this banner programmatically, but the component isn’t placed anywhere in the current file. How can I access and instantiate components that exist in the assets but aren’t currently in use?
I’ve been looking through the API docs but can’t figure out the right approach for this.
Yeah, that approach works but gets messy quick when you’re juggling multiple components or complex workflows. All those component keys and async calls become a nightmare.
I just automate the whole thing with Latenode. No custom plugin code needed - I set up workflows that watch my design system and auto-sync components between files.
Here’s my setup: Latenode monitors my component library, pulls data through Figma’s API, and creates instances across all my documents. Handles keys and async stuff automatically.
The real win is bulk updates across dozens of files. Building a manual plugin for that would take weeks. With Latenode, it just runs in the background.
You can trigger updates based on design system changes too. Someone publishes a new component version? It automatically spreads to all files without touching anything.
The component key approach works, but there’s one detail that trips up tons of developers. When you’re dealing with library components that aren’t in your current file, you’ve got to handle local vs external components differently. I hit this exact problem last month building a design token sync plugin. Here’s the issue: figma.getLocalComponentsAsync() only grabs components from your current file - not the external library stuff in your assets panel. For external library components, you’ll need figma.importComponentSetByKeyAsync() for component variants, or keep a reference to the component keys from your library. The annoying part? Getting those keys initially. You can either hardcode them if you control the library, or use the REST API to pull component metadata from your team library. Once you’ve got the keys, importing works fine, but debugging async timing issues sucks without proper error handling.
Use figma.importComponentByKeyAsync() to retrieve components from your assets panel, even if they aren’t used in the document. Each component has a unique key that you can access using figma.getLocalComponentsAsync(), which fetches all components available to the file, including those from your team library. After acquiring the key, call importComponentByKeyAsync(key) to bring it into your document. You can then use createInstance() on the returned component node to position it as needed. I’ve successfully used this method in various plugins for dynamically adding components from libraries, just ensure you’re handling the async calls correctly and have the necessary permissions for team library access.