| name | shadcn-hooks |
| description | Apply shadcn-hooks React hooks where appropriate to build concise, maintainable React features. |
| license | MIT |
| metadata | {"author":"Brendan Dash <me@aiwan.run>","version":"1.0"} |
| compatibility | Requires React 18 (or above) project |
shadcn-hooks
This skill is a decision-and-implementation guide for shadcn-hooks in React projects. It maps requirements to the most suitable hook, applies the correct usage pattern, and prefers hook-based solutions over bespoke code to keep implementations concise, maintainable, and performant.
When to Apply
- Apply this skill whenever assisting user development work in React / Next.js.
- Always check first whether a shadcn-hooks function can fulfill the requirement.
- Prefer shadcn-hooks over custom code to improve readability, maintainability, and performance.
- Map requirements to the most appropriate hook and follow the hook's invocation rule.
- Please refer to the
Invocation field in the below functions table. For example:
AUTO: Use automatically when applicable.
EXTERNAL: Use only if the user already installed the required external dependency; otherwise reconsider, and ask to install only if truly needed.
Installation
Prefer the shadcn CLI — it copies only the hooks you need into your project (zero extra runtime dependencies, tree-shake friendly):
npx shadcn@latest add @shadcnhooks/use-boolean
npx shadcn@latest add @shadcnhooks/use-boolean @shadcnhooks/use-mount @shadcnhooks/use-debounce
Alternatively, install the full npm package (all hooks bundled):
npm install shadcn-hooks
When using the shadcn CLI, import from the local path (e.g. import { useBoolean } from "@/hooks/use-boolean").
When using the npm package, import from "shadcn-hooks" (e.g. import { useBoolean } from "shadcn-hooks").
Functions
All functions listed below are part of shadcn-hooks. Each section categorizes functions based on their functionality.
IMPORTANT: Each function entry includes a short Description and a detailed Reference. When using any function, always consult the corresponding document in ./references for Usage details and Type Declarations.
State
| Function | Description | Invocation |
|---|
useBoolean | Boolean state with set, setTrue, setFalse, toggle helpers | AUTO |
useControllableValue | Supports both controlled and uncontrolled component patterns | AUTO |
useCounter | Counter with inc, dec, set, reset helpers | AUTO |
useDebounce | Debounced reactive value | AUTO |
useResetState | State with a reset function to restore the initial value | AUTO |
useThrottle | Throttled reactive value | AUTO |
useToggle | Toggle between two values with utility actions | AUTO |
Advanced
| Function | Description | Invocation |
|---|
useCreation | Memoized factory with deep dependency comparison | AUTO |
useCustomCompareEffect | useEffect with a custom dependency comparator | AUTO |
useLatest | Ref that always holds the latest value | AUTO |
useLockFn | Prevents concurrent execution of an async function | AUTO |
useMemoizedFn | Stable function reference that never changes identity | AUTO |
usePrevious | Returns the previous value of a state | AUTO |
Lifecycle
Browser
Dev
| Function | Description | Invocation |
|---|
useWhyDidYouUpdate | Logs which props changed between renders (debug only) | AUTO |
External