Skip to content
/ copee Public

πŸ“„ Copy text from browser to clipboard...natively! < 1kB

License

Notifications You must be signed in to change notification settings

styfle/copee

Folders and files

NameName
Last commit message
Last commit date

Latest commit

491c46f Β· Feb 2, 2025
Nov 9, 2022
Apr 1, 2018
May 2, 2020
May 25, 2020
Apr 2, 2018
Jul 23, 2015
Oct 13, 2017
Jun 18, 2020
Oct 14, 2017
May 25, 2020
Mar 11, 2018
Feb 2, 2025
Nov 2, 2023
Oct 14, 2017
Oct 14, 2017

Repository files navigation

copee

npm size install size Downloads Dependency Status devDependency Status Build Status

Copy text from browser to clipboard...natively! Less than 1 kB!

Have you ever wanted to send a string to the user's clipboard? Front-end developers have invented many hacks to get around this limitation...until now!

Introducing copee, a micro-wrapper around the browser's native "copy text" API πŸ—œοΈ

Death to Adobe Flash πŸ’€

Demo

Try the demo to see copee in action!

You can view the page source to quickly learn how to use it.

Also, read this blog post for some background.

Browser ESM Usage

<script type="module">
  import { toClipboard } from 'https://cdn.jsdelivr.net/npm/copee/dist/copee.mjs';

  document.getElementById('btn').addEventListener('click', () => {
    const success = toClipboard('Wow, "copee" works via ES Modules!');
    if (success) {
      // it worked, check your clipboard!
    }
  });
</script>

Browser UMD Usage

<script src="https://cdn.jsdelivr.net/npm/copee/dist/copee.umd.js"></script>
<script type="text/javascript">
  document.getElementById('btn').addEventListener('click', function () {
    var success = copee.toClipboard('Wow, "copee" works!');
    if (success) {
      // it worked, check your clipboard!
    }
  });
</script>

Browser Suppport

  • UMD (.js) supports IE 11+, Chrome 43+, Opera 29+, and Firefox 41+
  • ESM (.mjs) supports Chrome 61+, Safari 10.1+, Edge 16+, and Firefox 60+

Prior Art

This package was influenced by the following:

Authors

Developed by styfle