CKTIS / JavaScript
Navigator.clipboard — asynchronous clipboard access
Navigator.clipboard exposes a Clipboard object for asynchronous reading and writing of the system clipboard. It requires a secure context, and access is subject to browser restrictions.
Version: ECMAScript and Web APIs; exact feature edition and browser support reviewed per entry; Node 24 in repository does not prove browser API support
Syntax
navigator.clipboard
const text = await navigator.clipboard.readText();
await navigator.clipboard.writeText(text)Navigator.clipboard, accessed as navigator.clipboard, is a read-only property returning the same Clipboard object on repeated reads. It does not hold text directly: readText() returns a Promise for text, while writeText(text) returns a Promise fulfilled without a value after writing. read() and write() handle data represented by ClipboardItem.
This is a Web API, not an ECMAScript feature; Node 24 in a repository does not establish browser support. A secure context and a focused, active document are required. Permissions and user-activation requirements depend on the browser: invoke writing directly from a click and handle rejection, including NotAllowedError. Detecting a method does not guarantee access.
Unlike ClipboardEvent.clipboardData, which belongs to copy and paste events, this interface is asynchronous. The clipboard may contain sensitive data; read it only for a clearly defined purpose and warn before replacing its contents.
Examples
<!doctype html>
<html lang="en">
<head><meta charset="utf-8"><title>Navigator clipboard write</title></head>
<body>
<button type="button">Copy sample text</button>
<p role="status"></p>
<script>
const button = document.querySelector('button');
const status = document.querySelector('[role="status"]');
const clipboard = navigator.clipboard;
const canAttemptWrite = window.isSecureContext &&
typeof clipboard?.writeText === 'function';
status.textContent = canAttemptWrite
? 'Click to request a clipboard write.'
: 'Clipboard write is unavailable in this document.';
button.disabled = !canAttemptWrite;
console.log(status.textContent);
button.addEventListener('click', async () => {
try {
await clipboard.writeText('CKTIS');
status.textContent = 'Sample text copied.';
} catch (error) {
status.textContent = 'Clipboard write failed: ' + error.name;
}
});
</script>
</body>
</html>Result
Before interaction, the page reports whether a user-initiated clipboard write can be attempted. If it can, clicking the button reports either success or the browser's error name.
The displayed code and declared result were verified in an isolated environment using the method recorded in the verification evidence for this exact version.