Skip to content

useCopyToClipboard

Copies the given value to the clipboard using the Navigator API.

Usage

export function MyComponent() {
const [state, copyToClipboard] = useCopyToClipboard();
copyToClipboard("Hello, world!");
return <div>{state ? `Copied: ${state}` : "Copy something!"}</div>;
}

Installation

Terminal window
npx atmx add hook use-copy-to-clipboard