You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Cross-platform. Supports: macOS, Windows, Linux (including Wayland), OpenBSD, FreeBSD, Android with Termux, and modern browsers.
Install
npm install clipboardy
Usage
importclipboardfrom'clipboardy';awaitclipboard.write('π¦');awaitclipboard.read();//=> 'π¦'// Or use the synchronous APIclipboard.writeSync('π¦');clipboard.readSync();//=> 'π¦'
API
Browser usage: Requires a secure context (HTTPS). Synchronous methods are not available in browsers.
clipboard
.write(text)
Write (copy) to the clipboard asynchronously.
Returns a Promise<void>.
text
Type: string
The text to write to the clipboard.
awaitclipboard.write('π¦');
.read()
Read (paste) from the clipboard asynchronously.
Returns a Promise<string>.
constcontent=awaitclipboard.read();//=> 'π¦'
.writeSync(text)
Write (copy) to the clipboard synchronously.
Doesn't work in browsers.
text
Type: string
The text to write to the clipboard.
clipboard.writeSync('π¦');
.readSync()
Read (paste) from the clipboard synchronously.
Returns a string.
Doesn't work in browsers.
constcontent=clipboard.readSync();//=> 'π¦'
FAQ
Where can I find the source of the bundled binaries?
On Windows, clipboardy first tries the native PowerShell cmdlets (Set-Clipboard/Get-Clipboard) and falls back to the bundled binary if PowerShell is unavailable or restricted.
Does this work on Wayland?
Yes. On Linux, clipboardy automatically detects Wayland sessions and uses wl-clipboard when available. If not, it gracefully falls back to X11 tools. Also works with WSLg (Windows Subsystem for Linux GUI). Install wl-clipboard using your distribution's package manager.