Skip to content

Repository files navigation

copee

npmsizeinstall sizeDownloadsDependency StatusdevDependency StatusBuild 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

<scripttype="module">import{toClipboard}from'https://cdn.jsdelivr.net/npm/copee/dist/copee.mjs';document.getElementById('btn').addEventListener('click',()=>{constsuccess=toClipboard('Wow, "copee" works via ES Modules!');if(success){// it worked, check your clipboard!}});</script>

Browser UMD Usage

<scriptsrc="https://cdn.jsdelivr.net/npm/copee/dist/copee.umd.js"></script><scripttype="text/javascript">document.getElementById('btn').addEventListener('click',function(){varsuccess=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

About

📄 Copy text from browser to clipboard...natively! < 1kB

Topics

Resources

Security policy

Stars

154 stars

Watchers

2 watching

Forks

Releases

Packages

Contributors

Languages