How to implement copy to clipboard functionality in Figma plugins

I’ve been working on a Figma plugin for a project and I’m stuck on one specific feature. I need to create a button that copies certain content to the user’s clipboard when they click it.

I’ve seen this working in various Figma design systems and component libraries, but I can’t figure out the technical implementation. I’ve been searching through documentation and forums for quite a while now but haven’t found a clear solution.

Does anyone know how to properly set up clipboard functionality within Figma? I’m particularly interested in understanding the API calls or methods needed to make this work smoothly.

Any code examples or guidance would be really helpful. Thanks in advance!

hey! i just tackled this last week. u can use navigator.clipboard.writeText() in the UI code of ur plugin. just wrap that in a try-catch cause it can fail sometimes. clipboard access works fine from the UI side in figma plugins.