1. clipboardy
Access the system clipboard (copy/paste)
clipboardy
Package: clipboardy
Created by: sindresorhus
Last modified: Mon, 23 Oct 2023 08:10:35 GMT
Version: 4.0.0
License: MIT
Downloads: 16,608,848
Repository: https://github.com/sindresorhus/clipboardy

Install

npm install clipboardy
yarn add clipboardy

clipboardy

Access the system clipboard (copy/paste)

Cross-platform. Supports: macOS, Windows, Linux, OpenBSD, FreeBSD, Android with Termux, and modern browsers.

Install

 npm install clipboardy

Usage

 import clipboard from 'clipboardy';

clipboard.writeSync('🦄');

clipboard.readSync();
//=> '🦄'

API

In the browser, it requires a secure context.

clipboard

.write(text)

Write (copy) to the clipboard asynchronously.

Returns a Promise.

text

Type: string

The text to write to the clipboard.

.read()

Read (paste) from the clipboard asynchronously.

Returns a Promise.

.writeSync(text)

Write (copy) to the clipboard synchronously.

Doesn't work in browsers.

text

Type: string

The text to write to the clipboard.

.readSync()

Read (paste) from the clipboard synchronously.

Doesn't work in browsers.

FAQ

Where can I find the source of the bundled binaries?

The Linux binary is just a bundled version of xsel. The source for the Windows binary can be found here.

RELATED POST

10 Must-Know Windows Shortcuts That Will Save You Time

10 Must-Know Windows Shortcuts That Will Save You Time

Arrays vs Linked Lists: Which is Better for Memory Management in Data Structures?

Arrays vs Linked Lists: Which is Better for Memory Management in Data Structures?

Navigating AWS Networking: Essential Hacks for Smooth Operation

Navigating AWS Networking: Essential Hacks for Smooth Operation

Achieving Stunning Visuals with Unity's Global Illumination

Achieving Stunning Visuals with Unity's Global Illumination

Nim's Hidden Gems: Lesser-known Features for Writing Efficient Code

Nim's Hidden Gems: Lesser-known Features for Writing Efficient Code