<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/fix-navigator-clipboard-writetext-transient-activation-issues-mrm9tubve" -->

---
title: Fix navigator clipboard writeText transient activation...
description: Copy-to-clipboard buttons can silently fail with a NotAllowedError when navigator.clipboard.writeText() runs after an async operation like fetch or setTimeout,...
canonical: https://daily.dev/posts/fix-navigator-clipboard-writetext-transient-activation-issues-mrm9tubve
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: Fix navigator clipboard writeText transient activation Issues | daily.dev
og:description: Copy-to-clipboard buttons can silently fail with a NotAllowedError when navigator.clipboard.writeText() runs after an async operation like fetch or setTimeout,...
og:url: https://daily.dev/posts/fix-navigator-clipboard-writetext-transient-activation-issues-mrm9tubve
og:image: https://api.daily.dev/og/posts/Mrm9TuBve.png
og:image:alt: Fix navigator clipboard writeText transient activation Issues
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Fix navigator clipboard writeText transient activation Issues

**[SitePoint](https://daily.dev/sources/sitepoint)** · 15 min read · 1 upvotes · 0 comments

## Summary

Copy-to-clipboard buttons can silently fail with a NotAllowedError when navigator.clipboard.writeText() runs after an async operation like fetch or setTimeout, because the browser's transient user activation flag (roughly a 5-second window in Chromium and Firefox) expires while awaiting. The fix uses a lesser-known capability of ClipboardItem: passing a Promise<Blob> as its value so navigator.clipboard.write() can be called synchronously within the activation window while the actual content resolves later. This pattern is supported in Chromium 121+ and Safari 16.4+, with Firefox support partial, so a document.execCommand('copy') fallback is still recommended for broader coverage. The piece walks through reproduction, a reusable copyAfterAsync() utility, fallback detection strategy, and edge cases like iframe focus loss and rapid-click race conditions.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://www.sitepoint.com/fix-navigator-clipboard-writetext-transient-activation-async-javascript>

## Questions this post answers

### Why does navigator.clipboard.writeText() throw NotAllowedError after an await inside a click handler?

It fails because the browser's transient user activation flag, set when the user clicks, expires after roughly 5 seconds in current Chromium and Firefox implementations, and any await consumes wall-clock time against that window without pausing the timer. Once the window closes, the clipboard write is denied without a prompt. Programmatic or synthetic events never refresh the flag, only genuine hardware-initiated gestures do.

_Developers debugging silent clipboard failures can track browser quirks like this one on daily.dev._

### How can I copy text to the clipboard after an async fetch call without losing transient user activation?

Use the ClipboardItem constructor with a Promise<Blob> as the MIME type value, then call navigator.clipboard.write() synchronously inside the click handler before the async work resolves. The browser captures transient activation at the moment write() runs and defers reading the content until the promise settles, decoupling the activation check from content availability. This pattern is supported in Chromium 121+ and Safari 16.4+, with Firefox support remaining partial.

_Anyone shipping copy buttons that depend on API responses can revisit clipboard patterns like this via daily.dev._

### Which browsers support promise-based ClipboardItem values for clipboard.write()?

Chrome and Edge support it from version 121 onward, and Safari supports it from version 16.4 onward, both with full support for passing a Promise<Blob> as a ClipboardItem value. Firefox support remains partial and does not fully support promise-valued ClipboardItem in its stable release, so a document.execCommand('copy') fallback is still needed for broader compatibility.

_Developers weighing browser support before shipping clipboard code can check compatibility notes like this on daily.dev._

## Similar posts on daily.dev

- [A simple "copy this code" button in JavaScript](https://daily.dev/posts/a-simple-copy-this-code-button-in-javascript-1lsbtexwg) · Terence Eden · 2 upvotes · 0 comments
- [or why Cut & Paste is broken everywhere — Ishmael](https://daily.dev/posts/or-why-cut-paste-is-broken-everywhere-ishmael-lqvcxmaik) · Hacker News · 2 upvotes · 0 comments
- [December 11, 2025](https://daily.dev/posts/december-11-2025-y9uapefsn) · DevBlogs · 0 upvotes · 0 comments

---

Tags: [#webdev](https://daily.dev/tags/webdev), [#javascript](https://daily.dev/tags/javascript)

[View this post on daily.dev](https://daily.dev/posts/fix-navigator-clipboard-writetext-transient-activation-issues-mrm9tubve)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"Fix navigator clipboard writeText transient activation Issues","url":"https://daily.dev/posts/fix-navigator-clipboard-writetext-transient-activation-issues-mrm9tubve","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/fix-navigator-clipboard-writetext-transient-activation-issues-mrm9tubve"},"datePublished":"2026-09-03T18:34:08.611Z","dateModified":"2026-09-14T08:19:21.416Z","description":"Copy-to-clipboard buttons can silently fail with a NotAllowedError when navigator.clipboard.writeText() runs after an async operation like fetch or setTimeout,...","image":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/90d3173cd4ce9691d91baec4f8cad059?_a=AQAEuop","thumbnailUrl":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/90d3173cd4ce9691d91baec4f8cad059?_a=AQAEuop","isAccessibleForFree":true,"articleSection":"SitePoint","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"SitePoint","logo":"https://media.daily.dev/image/upload/t_logo,f_auto/v1/logos/sitepoint","url":"https://daily.dev/sources/sitepoint"},"commentCount":0,"discussionUrl":"https://daily.dev/posts/fix-navigator-clipboard-writetext-transient-activation-issues-mrm9tubve","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":1},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":0}],"keywords":"webdev,javascript","timeRequired":"PT15M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"SitePoint","item":"https://daily.dev/sources/sitepoint"},{"@type":"ListItem","position":3,"name":"Fix navigator clipboard writeText transient activation Issues"}]}
{"@context":"https://schema.org","@type":"FAQPage","@id":"https://daily.dev/posts/fix-navigator-clipboard-writetext-transient-activation-issues-mrm9tubve#faq","mainEntity":[{"@type":"Question","name":"Why does navigator.clipboard.writeText() throw NotAllowedError after an await inside a click handler?","acceptedAnswer":{"@type":"Answer","text":"It fails because the browser's transient user activation flag, set when the user clicks, expires after roughly 5 seconds in current Chromium and Firefox implementations, and any await consumes wall-clock time against that window without pausing the timer. Once the window closes, the clipboard write is denied without a prompt. Programmatic or synthetic events never refresh the flag, only genuine hardware-initiated gestures do. Developers debugging silent clipboard failures can track browser quirks like this one on daily.dev."}},{"@type":"Question","name":"How can I copy text to the clipboard after an async fetch call without losing transient user activation?","acceptedAnswer":{"@type":"Answer","text":"Use the ClipboardItem constructor with a Promise\u003cBlob\u003e as the MIME type value, then call navigator.clipboard.write() synchronously inside the click handler before the async work resolves. The browser captures transient activation at the moment write() runs and defers reading the content until the promise settles, decoupling the activation check from content availability. This pattern is supported in Chromium 121+ and Safari 16.4+, with Firefox support remaining partial. Anyone shipping copy buttons that depend on API responses can revisit clipboard patterns like this via daily.dev."}},{"@type":"Question","name":"Which browsers support promise-based ClipboardItem values for clipboard.write()?","acceptedAnswer":{"@type":"Answer","text":"Chrome and Edge support it from version 121 onward, and Safari supports it from version 16.4 onward, both with full support for passing a Promise\u003cBlob\u003e as a ClipboardItem value. Firefox support remains partial and does not fully support promise-valued ClipboardItem in its stable release, so a document.execCommand('copy') fallback is still needed for broader compatibility. Developers weighing browser support before shipping clipboard code can check compatibility notes like this on daily.dev."}}]}
```

