Registry / serialization / tinyclip

tinyclip

JSON →
library0.1.12jsnpmunverified

tinyclip is a concise, cross-platform utility designed to interact with the system clipboard specifically within Node.js environments. It leverages native operating system clipboard functionalities for robust performance. The package is currently at version `0.1.12` and demonstrates an active development cadence, with frequent minor updates addressing features and bug fixes. A key differentiator is its minimalistic design and its exclusive focus on Node.js; starting from version `0.1.11`, `tinyclip` explicitly removed browser support, guiding developers to utilize the native browser Clipboard API for web contexts instead. This makes it an ideal choice for server-side or desktop applications built with Node.js that require reliable clipboard operations without additional heavy dependencies.

npm install tinyclip
INSTALL
IMPORT
SIG · TINYCLIP
T
tinyclip
serializationjavascriptv0.1.12
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

readText
import { readText } from 'tinyclip'
const { readText } = require('tinyclip')
tinyclip is an ESM-first library. CommonJS `require` is not directly supported and will lead to import errors.
writeText
import { writeText } from 'tinyclip'
const writeText = require('tinyclip').writeText
Ensure your Node.js environment is configured for ESM (e.g., `package.json` with `"type": "module"` or using `.mjs` files).

Demonstrates how to write a string to the system clipboard and then read its content back, within a Node.js environment.

import { readText, writeText } from 'tinyclip'; async function clipboardExample() { const textToCopy = 'Hello from tinyclip! This text was written to your clipboard.'; console.log(`Attempting to write: "${textToCopy}" to clipboard.`); try { await writeText(textToCopy); console.log('Text successfully written to clipboard.'); console.log('Attempting to read text from clipboard...'); const clipboardContent = await readText(); console.log(`Text read from clipboard: "${clipboardContent}"`); if (clipboardContent === textToCopy) { console.log('Clipboard content matches the written text.'); } else { console.log('Clipboard content does not match the written text. (This might be due to other applications modifying the clipboard or environment limitations)'); } } catch (error: any) { console.error('Failed to interact with clipboard:', error.message); console.error('Ensure you are running in a Node.js environment with appropriate OS access.'); } } clipboardExample();
Debug
Known issues
breakingBrowser support was entirely removed in version `0.1.11`. Attempts to use `tinyclip` in a browser environment after this version will result in errors.
fix
For browser environments, use the native `navigator.clipboard` API (e.g., `navigator.clipboard.readText()` or `navigator.clipboard.writeText()`).
affects: >=0.1.11
breakingNode.js engine constraints were introduced in version `0.1.12`, requiring Node.js versions `^16.14.0 || >= 17.3.0`.
fix
Ensure your Node.js environment meets the specified version requirements. Update Node.js if necessary to avoid installation or runtime issues.
affects: >=0.1.12
gotchaThis library is exclusively designed for Node.js environments. Although older versions might have had limited browser compatibility, it is no longer maintained nor supported for web applications.
fix
Always use native browser `Clipboard API` (e.g., `navigator.clipboard.readText()`) for web applications to ensure compatibility and leverage browser security models.
affects: *
Errors
Common errors & fixes
ReferenceError: document is not defined
Attempting to use `tinyclip` in a browser environment after its browser support was removed in version `0.1.11`.
fix
This library is Node.js-only since v0.1.11. For browser applications, use the native `navigator.clipboard` API.
SyntaxError: Named export 'readText' not found. The requested module 'tinyclip' is a CommonJS module, which may not support named exports.
Trying to import `tinyclip` using CommonJS `require()` syntax or using named imports (`import { ... }`) in a CommonJS context without proper ESM setup.
fix
Ensure your Node.js project is configured for ECMAScript Modules (ESM) by setting `"type": "module"` in your `package.json` or by using `.mjs` file extensions, and use `import { readText, writeText } from 'tinyclip';`.
Upgrade
Version history
0.1.12latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
11 hits · last 30 days
node
10
OpenAI (training)
1
Resources
tinyclip — npm install tinyclip · libregistry