const copyText = (textToCopy) =>
navigator.clipboard.writeText(textToCopy).then(
() => {
/* clipboard successfully set */
},
() => {
/* clipboard write failed */
}
);Clipboard.writeText() documentation↗
The user has to interact with the page or a UI element in order for this feature to work (would need to call the
copyTextfunction in an event listener).The
"clipboard-write"permission of thePermissions APIis granted automatically to pages when they are in the active tab.