ai-agent
Copy to Clipboard with clipboard.js
Easily copy text to clipboard with this lightweight tool, ideal for startup founders, backed by 34k+ GitHub stars
34,130 stars3,909 forksJavaScriptHealth Score 8/10Updated 2/12/2026100% free · open source
What it does
Clipboard.js is a lightweight JavaScript tool that allows you to easily copy text to the user's clipboard without using Flash.
Install / run
npm install clipboardWhen to use it
- •When you need to provide a simple way for users to copy text, such as a password or a coupon code.
- •When you want to enhance the user experience by reducing the number of steps required to copy text.
- •When you need to support older browsers that do not have native copy to clipboard functionality.
Quick start
- 1Include the Clipboard.js script in your HTML file: <script src="https://cdnjs.cloudflare.com/ajax/libs/clipboard.js/2.0.6/clipboard.min.js"></script>
- 2Create a DOM element with a data-clipboard-text attribute, such as a button: <button class="btn" data-clipboard-text="Hello World!">Copy to Clipboard</button>
- 3Initialize the Clipboard.js instance: const clipboard = new ClipboardJS('.btn');
- 4Use the success and error callbacks to handle the copy event: clipboard.on('success', function(e) { console.log(e); });
- 5Test the functionality by clicking the button and verifying that the text is copied to the clipboard.
Ready-to-paste prompt
new ClipboardJS('.btn', { text: function() { return 'Hello, ' + document.getElementById('name').value; } });Heads up: Make sure the DOM element with the data-clipboard-text attribute is not hidden or disabled, as this can prevent the copy event from triggering.
Saves to your device
Topics
clipboard
javascript
How Copy to Clipboard with clipboard.js works
Codeflow
Free to inspect
Copy to Clipboard with clipboard.js is a tiny JavaScript project (~350 lines across 11 code files, plus 6 test files). Setup is light: installs like a normal app. Reading the code is optional. Last commit 6 months ago, MIT license, has a test suite.
Size
Tiny codebase
~350 lines · 11 code files · 3 min skim
Setup
One-command install
Installs like a normal app. Reading the code is optional.
Runs on
Node.js
No API keys detected
JavaScript 99%TypeScript 1%
Where to start reading
- 1readme.mdStart here — what it does and how to install it
- 2composer.jsonDependencies and the commands it exposes
- 3src/clipboard.d.tsInside src/ — the main logic begins here
- 4demo/constructor-node.htmlA worked example — copy this to get going
What's in each folder
READMEHas testsDocumentedCI checksExamples includedMIT licenseLast update 6 mo ago
Details
Creator
zenorocha
Language
JavaScript
Category
ai-agent
Published
9/18/2015
Are you the creator of this tool? Claim your listing → and earn 85% of every sale.
Related skills
More ai-agent tools founders pair with this one.
ai-agent★ 276,436
Track GitHub Stars with 996.ICU
Get a popular GitHub star counter for your startup, backed by 276k+ GitHub stars, ideal for founders.
ai-agent★ 264,191
Superpowers
An agentic skills framework & software development methodology that works.
ai-agent★ 244,424
Linux: Open Source Kernel
Get the Linux kernel source tree for custom development, ideal for startup founders in need of a flexible OS foundation with 236k+ GitHub stars
ai-agent★ 204,069
Improve Code with andrej-karpathy-skills
Get better code behavior with andrej-karpathy-skills, 165k+ GitHub stars, for founders using LLMs.
ai-agent★ 189,101
Simplify Zsh with ohmyzsh
Get a customizable terminal experience with ohmyzsh, perfect for startup founders, backed by 188k+ GitHub stars.
ai-agent★ 187,262
FreeDomain: Free Website Domain
Get a free domain with FreeDomain. For startup founders.