In Electron API, there are some modules that can be accessed from both renderer process and main process. Clipboard is such module that is available in both processes. This module can be used to access the clipboard data, which is present inside the native operating system. It provides a rich set of API to manipulate the clipboard data. Here is a small example that writes the text content of a paragraph element in DOM to the clipboard on the click of a button:
<!DOCTYPE html> <html> <head> <script type="text/javascript"> const { dialog, clipboard } = require('electron').remote; window.onload = function () { document.getElementById('btn').onclick = function () { let el = document.getElementById('content'); clipboard.writeText(el.innerText); dialog.showMessageBox({ type: 'info', buttons: ['Ok'], message: 'Text copied to the clipboard!', }); }; }; </script> </head> ...