Open In App

Clipboard API in ElectronJS

ElectronJS is an Open Source Framework used for building Cross-Platform native desktop applications using web technologies such as HTML, CSS, and JavaScript which are capable of running on Windows, macOS, and Linux operating systems. It combines the Chromium engine and NodeJS into a Single Runtime.

Sometimes developers would like more granular control over basic System behavior such as copy and paste operations. Electron provides us access to the System Clipboard using the built-in clipboard module for this very purpose. Using the clipboard module developers can provide copy and paste functionality for different formats such as an Image file, plain text, HTML markup, etc, using the different Instance methods of this module. This tutorial will demonstrate the different operations supported by the Clipboard API in Electron.



We assume that you are familiar with the prerequisites as covered in the above-mentioned link. For Electron to work, node and npm need to be pre-installed in the system.

Clipboard API in Electron: The clipboard module is used for performing copy and paste operations on the system clipboard. The system clipboard is used throughout the System OS environment and hence any copy-paste operation performed in the Electron application is valid throughout the System OS. The clipboard module can be directly used in the Main Process as well as the Renderer Process of the application. Hence we do not need the Electron remote module to import it.



Example: Follow the give Steps to implement Clipboard API in Electron.


Article Tags :