clipboard.js
A modern, Flash-free JavaScript library for copying and cutting text to the clipboard
Repository Health
Technical Analysis
clipboard.js is a small JavaScript library that adds copy-to-clipboard and cut-to-clipboard behavior to any DOM element without relying on Flash or requiring inline onclick handlers. It works declaratively by attaching a data-clipboard-target or data-clipboard-text attribute to a trigger element, and internally uses the browser’s execCommand/Clipboard APIs behind a small event-emitter-based API.
The library ships no framework dependency and is commonly embedded in documentation sites, code-snippet blocks, and share/link buttons where a single click needs to copy specific text without a page reload or plugin.
What You Get
- Declarative copy/cut triggers via
data-clipboard-targetordata-clipboard-textattributes - No Flash dependency — pure JavaScript wrapping native browser clipboard APIs
- A small event emitter API (
success/errorevents) for custom UI feedback (e.g. “Copied!” tooltips) - Framework-agnostic usage, plus TypeScript type definitions bundled in the package
- A tiny bundle size (a few kilobytes gzipped) suitable for documentation and marketing sites
Common Use Cases
- “Copy code” buttons on documentation sites and code-snippet blocks
- “Copy link” or “copy referral code” buttons on marketing and account pages
- Copying generated values (API keys, invite codes, share URLs) to the clipboard with one click
- Adding clipboard support to static sites or CMS-driven pages without a full JS framework
Under The Hood
Architecture: The core (src/clipboard.js, ~165 lines) is a class extending a small tiny-emitter-based event emitter, delegating actual clipboard mutation to two action modules under src/actions/ (copy and cut), and using the good-listener and select helper packages for event delegation and text selection respectively. This separation keeps the core class focused on wiring DOM events to the appropriate action rather than implementing selection/copy logic inline.
Tech Stack: Plain JavaScript (ES5-targeted output) with three small first-party-maintained dependencies (good-listener, select, tiny-emitter) rather than a large dependency tree; built via Webpack for the distributable bundle and tested with Karma across real browsers.
Code Quality: The test/ directory mirrors the src/ structure (actions/, common/), indicating unit coverage per module rather than only integration tests. TypeScript definitions (clipboard.d.ts) and a .test-d.ts type-test file show attention to consumer type safety despite the library itself being plain JS.
API Design: The declarative data-clipboard-target/data-clipboard-text attribute API is the library’s signature ergonomic choice — it lets developers add copy behavior without writing any imperative JS beyond instantiating new ClipboardJS(selector), making the learning curve very shallow for the common case.
Used by 12 apps in this directory
APITable
Low Code Platforms · Databases
API-first collaborative spreadsheet-database platform that auto-generates REST APIs and lets teams build internal tools, CRMs, and dashboards without code.
Authelia
Security · Authentication
OpenID Certified SSO and MFA portal for securing self-hosted web applications behind reverse proxies.
ezBookkeeping
Invoicing Finance
Lightweight self-hosted personal finance manager with AI receipt scanning, multi-currency support, and MCP integration for complete data privacy.
GitLab
Devops · Developer Tools
The complete DevOps platform that unifies Git hosting, CI/CD, issue tracking, and security scanning into a single self-hostable application.
hoop
Security · Monitoring
A wire-protocol gateway that enforces data masking, command blocking, approval workflows, and full session recording for engineers and AI agents accessing production infrastructure.
Invoice Ninja
Invoicing Finance · Project Management
Self-hostable invoicing, time-tracking, and multi-gateway payment platform for freelancers and small businesses, with built-in e-invoicing compliance for EU and global standards.
NodeBB
Community
Modern Node.js forum software with real-time WebSockets, multi-database support, and a plugin ecosystem — the community platform built for the open web and the Fediverse.
Super Productivity
Productivity · Project Management
A privacy-respecting, local-first task manager with built-in timeboxing, Pomodoro timer, and deep integrations for Jira, GitHub, GitLab, and CalDAV — no accounts, no data collection, ever.
Vanguard Backup
Devops
Self-hosted backup automation for Ubuntu and Debian servers with S3 storage, SSH-based file and database backup, and multi-channel notifications.