useClipboard
useClipboard(
options?):UseClipboardReturn
Defined in: src/hooks/useClipboard/useClipboard.ts:70
Copy text to the clipboard with a built-in timeout-driven feedback state.
Uses navigator.clipboard.writeText when available; falls back to
document.execCommand('copy') only when the modern API is missing.
In SSR or restricted contexts where neither path is available, copy
resolves to false and status flips to 'error' without throwing.
Parameters
options?
UseClipboardOptions = {}
Returns
Example
const { copy, copied } = useClipboard({ timeout: 1500 });
return ( <Button onClick={() => copy('Hello!')}> {copied ? 'Copied!' : 'Copy'} </Button>);