clipboard.copyText() not working + getting error

Hi there,

I’m creating a plugin for XD (working on MacOS Big Sur), and trying to be able to copy some text to the clipboard, but am getting an error in the dev console. Tried googling it but nothing came up. This is the error:

Uncaught Error: Clipboard access not supported for 3P plugins with manifest version upto 4. Valid manifest entry required from manifest version 5.

This is my code:

<WC onClick={() => {clipboard.copyText(textToCopy)}}>
   <sp-body size="S">{`Here is your link: ${textToCopy}`}</sp-body>
</WC>

Any help is appreciated! Thank you!

Are you using manifest v3, which is the latest version that XD supports? If so, could you please attach an entire plugin that illustrates the problem so that I can debug?

Yes, I’m using manifest v3. The plugin requires a login and calls a local server, returning some data so you might not be able to get to that particular section.

I’m wondering if it’s because the text I’m trying to copy is in the panel, as opposed to text in the artboard? But in my terminal, the error I’m getting is this, so I don’t think so?

ERROR in ./src/components/ComponentName.js Module not found: Error: Can't resolve 'clipboard' in '/Users/.../src/components'

I’m importing it like so: import clipboard from 'clipboard'; to match all my other imports (which works).

I tried:

import clipboard from 'clipboard';
import { clipboard } from 'clipboard';
import * as clipboard from 'clipboard';

I also tried ClipboardEvent (because it was available in dev console), but got the same error.

Let me know if you need more info and I can privately DM a version of the app that doesn’t require a local server running.

Hi! Just wanted to say we’ve figured this out.

In the webpack.config.js file, I needed to add clipboard: 'clipboard' to externals: {}

1 Like