/** * Return value for the useClipboard hook */ interface UseClipboardReturnValue { /** * The current text content from the clipboard */ text: string | null; /** * Copy text to the clipboard * @param value - The text to copy * @returns Promise that resolves when copy is complete */ copy: (value: string) => Promise; /** * Read text from the clipboard * @returns Promise that resolves when read is complete */ paste: () => Promise; /** * Whether the Clipboard API is supported */ isSupported: boolean; /** * Any error that occurred during clipboard operations */ error: Error | null; } /** * useClipboard hook * * Read from and write to the system clipboard using the Clipboard API. * Provides methods to copy text to clipboard and read text from clipboard, * along with support detection and error handling. * * @returns Object containing clipboard operations and state * * @example * ```tsx * import { useClipboard } from "rooks"; * * function ClipboardDemo() { * const { copy, paste, text, isSupported, error } = useClipboard(); * const [inputValue, setInputValue] = useState(""); * * const handleCopy = async () => { * await copy(inputValue); * }; * * const handlePaste = async () => { * await paste(); * }; * * if (!isSupported) { * return
Clipboard API not supported
; * } * * return ( *
* setInputValue(e.target.value)} * placeholder="Enter text to copy" * /> * * * {text &&

Clipboard: {text}

} * {error &&

Error: {error.message}

} *
* ); * } * ``` * * @see https://rooks.vercel.app/docs/hooks/useClipboard */ declare function useClipboard(): UseClipboardReturnValue; export { useClipboard }; export type { UseClipboardReturnValue };