Using the new Async Clipboard API

Shipping with Chrome 66 is an implementation of the new Async Clipboard API. Its asynchronous nature makes it the preferred way – over document.execCommand – to perform copy-paste operations in the browser. // Write Text to the Clipboard (e.g. copy) navigator.clipboard.writeText(‘Text to be copied’) .then(() => { console.log(‘Text copied to clipboard’); }) .catch(err => { …

Clipboard.js

<!– Target –> <input id="foo" value="https://github.com/zenorocha/clipboard.js.git"> <!– Trigger –> <button class="btn" data-clipboard-target="#foo"> <img src="assets/clippy.svg" alt="Copy to clipboard"> </button> Copying text to the clipboard shouldn’t be hard. It shouldn’t require dozens of steps to configure or hundreds of KBs to load. But most of all, it shouldn’t depend on Flash or any bloated framework. That’s why …