Changelog - 2026-11-04
useCopyToClipboard returns isCopied, with a resetMs option
New FeatureIn one line. useCopyToClipboard({ resetMs }) returns { copy, isCopied }: isCopied is the result of the last copy, and with resetMs it goes back to false after that many milliseconds.
tsx
import { useCopyToClipboard } from '@venizia/ardor';
export function CopyShareLink(props: { url: string }) {
const { copy, isCopied } = useCopyToClipboard({ resetMs: 2000 });
return <button onClick={() => copy({ value: props.url })}>{isCopied ? 'Copied' : 'Share'}</button>;
}What changed
isCopiedis part of the hook. A new copy restarts the timer, a refused copy setsisCopiedtofalse, and the timer is cleared on unmount. WithoutresetMs, or with0or less,isCopiedstays as the last copy left it.copyis as before. It resolvestruewhen the text is on the clipboard andfalseotherwise, never throws, and keeps its identity across renders as long asresetMsis the same.- A new type.
IUseCopyToClipboardOptionsis the options object.
Who is affected
- An app that keeps a state and a timer around
useCopyToClipboardfor a "Copied" label. You can passresetMsand readisCopiedinstead. - All other apps. No action needed:
const { copy } = useCopyToClipboard()still works.
See Hooks.