Small hooks for everyday React
Debounce, media queries, clipboard, composed refs, and stable IDs. Each hook has its own subpath, so you only bundle what you import.
useDebounce
Holds a value until typing settles, with a configurable delay in milliseconds.
useComposedRefs
Merges callback refs, ref objects, and forwarded refs into one. It’s the plumbing behind
asChild.useCopyToClipboard
Copies any string with the async clipboard API and remembers the last value, ready for a toast.
useMediaQuery
Subscribes to any media query, like
(prefers-reduced-motion)or(max-width: 768px). SSR-safe, with a configurable default.useStableId
SSR-safe, stable IDs for ARIA attributes. Built on
React.useId()with a readable prefix.scheduleTransitionTimeout
Times work to an element’s computed
transition-duration, so you never hardcode a timeout.
Install
Import each hook from its own subpath.
Install
bun add @gentleduck/hooksImport a hook
import { useDebounce } from '@gentleduck/hooks/use-debounce'
Free & open source
gentleduck is MIT licensed and will always be free and open source. Every package ships with full source access — fork it, modify it, own it.