{"id":12146,"library":"tinyclip","title":"tinyclip - System Clipboard Utility","description":"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.","status":"active","version":"0.1.12","language":"javascript","source_language":"en","source_url":"https://github.com/tinylibs/tinyclip","tags":["javascript","clipboard","copy","paste","typescript"],"install":[{"cmd":"npm install tinyclip","lang":"bash","label":"npm"},{"cmd":"yarn add tinyclip","lang":"bash","label":"yarn"},{"cmd":"pnpm add tinyclip","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"tinyclip is an ESM-first library. CommonJS `require` is not directly supported and will lead to import errors.","wrong":"const { readText } = require('tinyclip')","symbol":"readText","correct":"import { readText } from 'tinyclip'"},{"note":"Ensure your Node.js environment is configured for ESM (e.g., `package.json` with `\"type\": \"module\"` or using `.mjs` files).","wrong":"const writeText = require('tinyclip').writeText","symbol":"writeText","correct":"import { writeText } from 'tinyclip'"}],"quickstart":{"code":"import { readText, writeText } from 'tinyclip';\n\nasync function clipboardExample() {\n  const textToCopy = 'Hello from tinyclip! This text was written to your clipboard.';\n  console.log(`Attempting to write: \"${textToCopy}\" to clipboard.`);\n  try {\n    await writeText(textToCopy);\n    console.log('Text successfully written to clipboard.');\n\n    console.log('Attempting to read text from clipboard...');\n    const clipboardContent = await readText();\n    console.log(`Text read from clipboard: \"${clipboardContent}\"`);\n\n    if (clipboardContent === textToCopy) {\n      console.log('Clipboard content matches the written text.');\n    } else {\n      console.log('Clipboard content does not match the written text. (This might be due to other applications modifying the clipboard or environment limitations)');\n    }\n  } catch (error: any) {\n    console.error('Failed to interact with clipboard:', error.message);\n    console.error('Ensure you are running in a Node.js environment with appropriate OS access.');\n  }\n}\n\nclipboardExample();","lang":"typescript","description":"Demonstrates how to write a string to the system clipboard and then read its content back, within a Node.js environment."},"warnings":[{"fix":"For browser environments, use the native `navigator.clipboard` API (e.g., `navigator.clipboard.readText()` or `navigator.clipboard.writeText()`).","message":"Browser support was entirely removed in version `0.1.11`. Attempts to use `tinyclip` in a browser environment after this version will result in errors.","severity":"breaking","affected_versions":">=0.1.11"},{"fix":"Ensure your Node.js environment meets the specified version requirements. Update Node.js if necessary to avoid installation or runtime issues.","message":"Node.js engine constraints were introduced in version `0.1.12`, requiring Node.js versions `^16.14.0 || >= 17.3.0`.","severity":"breaking","affected_versions":">=0.1.12"},{"fix":"Always use native browser `Clipboard API` (e.g., `navigator.clipboard.readText()`) for web applications to ensure compatibility and leverage browser security models.","message":"This 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.","severity":"gotcha","affected_versions":"*"}],"env_vars":null,"last_verified":"2026-04-19T00:00:00.000Z","next_check":"2026-07-18T00:00:00.000Z","problems":[{"fix":"This library is Node.js-only since v0.1.11. For browser applications, use the native `navigator.clipboard` API.","cause":"Attempting to use `tinyclip` in a browser environment after its browser support was removed in version `0.1.11`.","error":"ReferenceError: document is not defined"},{"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';`.","cause":"Trying to import `tinyclip` using CommonJS `require()` syntax or using named imports (`import { ... }`) in a CommonJS context without proper ESM setup.","error":"SyntaxError: Named export 'readText' not found. The requested module 'tinyclip' is a CommonJS module, which may not support named exports."}],"ecosystem":"npm"}