The Clipboard API lets you copy and read clipboard content. It requires user permission.
// Copy text
await navigator.clipboard.writeText("Copied!");
// Read text (needs permission)
const text = await navigator.clipboard.readText();
This replaces the old document.execCommand('copy') approach.