{
  "name": "use-copy-to-clipboard",
  "type": "registry:hook",
  "description": "React hook that copies text to the clipboard and exposes a copied state with a reset timeout.",
  "files": [
    {
      "type": "registry:hook",
      "content": "import * as React from \"react\";\n\nexport function useCopyToClipboard({\n  timeout = 2000,\n  onCopy,\n}: {\n  timeout?: number;\n  onCopy?: () => void;\n} = {}) {\n  const [isCopied, setIsCopied] = React.useState(false);\n\n  const copyToClipboard = (value: string) => {\n    if (typeof window === \"undefined\" || !navigator.clipboard.writeText) {\n      return;\n    }\n\n    if (!value) return;\n\n    navigator.clipboard.writeText(value).then(() => {\n      setIsCopied(true);\n\n      if (onCopy) {\n        onCopy();\n      }\n\n      setTimeout(() => {\n        setIsCopied(false);\n      }, timeout);\n    }, console.error);\n  };\n\n  return { isCopied, copyToClipboard };\n}\n",
      "path": "/hooks/use-copy-to-clipboard.ts",
      "target": "hooks/use-copy-to-clipboard.ts"
    }
  ]
}