ts
import { useCopyToClipboard } from "@arkyn/components/useCopyToClipboard";
{ copyToClipboard: (text: string) => Promise<boolean> }copyToClipboard — (text: string) => Promise<boolean>. Copies text to the clipboard. Resolves to true on success, false on failure. Never throws.tsx
import { useCopyToClipboard } from "@arkyn/components/useCopyToClipboard";function CopyButton({ value }) {const { copyToClipboard } = useCopyToClipboard();async function handleClick() {const success = await copyToClipboard(value);if (success) console.log("Copied!");}return <button onClick={handleClick}>Copy</button>;}
navigator.clipboard.writeText first. If it's unavailable or rejects, it falls back to a hidden <textarea> with document.execCommand("copy").copyWithFallback, for insecure contexts (non-HTTPS) or older browsers that don't support the Clipboard API.false.