Oliver Jumpertz

Using The Clipboard

Category: JavaScript

Share this snippet to:

const { clipboard } = navigator;
await clipboard.writeText("This text comes out of your clipboard!");
const clipboardContent = await clipboard.readText();

Explanation

The clipboard API allows you to access a user’s clipboard. It’s for example what allows you to copy the contents of the code snippet above by clicking on the clipboard icon in the upper right corner.

Nothing too special, but great for usability if you want to allow people to quickly get something off your site without having to copy is manually.


Share this snippet to: