The Clipboard API: How Did We Get Here?
cekrem.github.io·7h·
Flag this post

I’m writing a book about Elm for React developers. In the JavaScript interop chapter, I needed a simple example of calling a browser API from Elm through a port. Something straightforward, universally useful, not too trivial.

“Perfect,” I thought. “Let’s copy text to the clipboard.”

The Search Link to heading

Out of curiosity, I checked npm for clipboard packages:

Over 1000 packages for clipboard operations

Over one thousand packages. For copying text to the clipboard.

Let that sink in for a moment.

The “Simple” Solution Link to heading

The modern approach looks like this:

navigator.clipboard
.writeText(text)
.then(() => con...

Similar Posts

Loading similar posts...