clipboardy
Cross-platform clipboard read/write for Node.js CLIs, supporting macOS, Linux, and Windows with sync and async APIs.
Official Documentation ↗v5.3.2. Check the official docs for the latest API surface.Installation
npm install clipboardyMethods
No methods match this filter.
clipboardy is cross-platform clipboard read/write for node.js clis, supporting macos, linux, and windows with sync and async apis. This page documents the core methods, installation, and common usage patterns for the current stable release.
Installation
Install clipboardy with your preferred package manager using the command shown in the frontmatter. The package is published to the npm registry and ships with TypeScript types where applicable.
Core methods
The methods listed in the frontmatter cover the primary API surface. Each signature reflects the v4.0 release. Consult the official documentation linked in sourceUrl for advanced options, edge cases, and breaking changes between major versions.
Frequently asked questions
The faq section in the frontmatter answers the most common questions about clipboardy, including comparisons with alternatives, configuration tips, and runtime requirements. If your question is not covered, check the source URL for the full guide.
Security
Official security statements captured from the package documentation:
- 浏览器端使用需安全上下文(HTTPS),且同步方法在浏览器不可用 — “Browser usage: Requires a secure context (HTTPS). Synchronous methods are not available in browsers.” (source: https://raw.githubusercontent.com/sindresorhus/clipboardy/main/readme.md, fetched 2026-11-08T19:27:00+08:00)
API reference evidence
Fetched from official sources on 2026-11-08T19:27:00+08:00 via WebFetch https://raw.githubusercontent.com/sindresorhus/clipboardy/main/readme.md(另尝试 index.d.ts 两次均返回空内容,未取得类型声明).
writeSync→ signature from https://raw.githubusercontent.com/sindresorhus/clipboardy/main/readme.md; official text: “#### .writeSync(text) Write (copy) to the clipboard synchronously. Doesn’t work in browsers. ##### text Type:stringThe text to write to the clipboard.”readSync→ signature from https://raw.githubusercontent.com/sindresorhus/clipboardy/main/readme.md; official text: “#### .readSync() Read (paste) from the clipboard synchronously. Returns astring. Doesn’t work in browsers.”write→ signature from https://raw.githubusercontent.com/sindresorhus/clipboardy/main/readme.md; official text: “#### .write(text) Write (copy) to the clipboard asynchronously. Returns aPromise<void>.”
FAQ
- How does it work on Linux?
- It uses xclip or xsel; install one of them on headless systems.
- Does it work over SSH?
- Only if X11 forwarding is enabled; otherwise the clipboard tool has no display.
- Is it ESM-only?
- v4 is ESM-only; use v3 for CommonJS support.
Report a problem with this API docOpens a pre-filled issue on GitHub.