Copies text, JSON objects, images, or plain blobs to the user's clipboard.
Note, it can throw either because navigation.clipboard is not supported or new Blob or ClipboardItem themselves throw.
await copyToClipboard("Hello World!").catch(handleError)await copyToClipboard({ id: 101, roles: ["admin"] }).catch(handleError)const response = await fetch("https://example.com/image.png")const imageBlob = await response.blob()await copyToClipboard(imageBlob); Copy
await copyToClipboard("Hello World!").catch(handleError)await copyToClipboard({ id: 101, roles: ["admin"] }).catch(handleError)const response = await fetch("https://example.com/image.png")const imageBlob = await response.blob()await copyToClipboard(imageBlob);
Optional
Optional explicit MIME type override for Blobs or custom formats
Copies text, JSON objects, images, or plain blobs to the user's clipboard.
Note, it can throw either because navigation.clipboard is not supported or new Blob or ClipboardItem themselves throw.