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...

Keyboard Shortcuts

Navigation
Next / previous item
j/k
Open post
oorEnter
Preview post
v
Post Actions
Love post
a
Like post
l
Dislike post
d
Undo reaction
u
Recommendations
Add interest / feed
Enter
Not interested
x
Go to
Home
gh
Interests
gi
Feeds
gf
Likes
gl
History
gy
Changelog
gc
Settings
gs
Browse
gb
Search
/
General
Show this help
?
Submit feedback
!
Close modal / unfocus
Esc

Press ? anytime to show this help