How to copy text to the clipboard in Electron

Copying text to the clipboard using Electron:

jsx
let text = 'Electron rocks!';

window.clipboard.writeText(text);

// Text is in the clipboard after this point

You can call this method from the App.js. That's it.

Hi, I'm Erik, an engineer from Barcelona. If you like the post or have any comments, say hi.