'use client' import { useCallback, useState } from 'react' /** Writes text to the clipboard and flags the copied key briefly (for a check-mark affordance). */ export function useClipboard(resetMs = 1500) { const [copiedKey, setCopiedKey] = useState(null) const copy = useCallback( (key: string, text: string) => { void navigator.clipboard?.writeText(text) setCopiedKey(key) window.setTimeout(() => setCopiedKey((k) => (k === key ? null : k)), resetMs) }, [resetMs], ) return { copiedKey, copy } }