All Hooks
this project was heavily inspired by usehooks.dev and built with the purpose of increasing qwik ecosystem. by: @victorditadi

useCopyClipboard

Copy text to the clipboard using useCopyClipboard.

INSTALL:
npm i @ditadi/qwik-hooks
DESCRIPTION:The useCopyToClipboard hook is useful because it abstracts the complexity of copying text to the clipboard in a cross-browser compatible manner. It utilizes the modern navigator.clipboard.writeText method if available, which provides a more efficient and secure way to copy text. In case the writeText method is not supported by the browser, it falls back to a traditional method using the document.execCommand(“copy”) approach
PARAMETERS
NameTypeDescription
timeoutnumber (optional)The timeout in milliseconds to execute the copy operation. Default is 300ms.
RETURN VALUEThe useCopyClipboard hook returns an array with the following elements:
NameTypeDescription
copySignal<string | boolean | null>The value that was last copied to the clipboard.
setCopyQRL<(value: string | boolean | null) => Promise<void>>A function to copy a specified value to the clipboard.
isCopyingSignal<boolean>A boolean signal that indicates whether the copy operation is in progress.
DEMO:
click at button to copy
Example: