mcpField
S
shadcn-hooks

shadcn-hooks

github.com/debblDevelopment6181 installsUpdated 6w ago
Repository

About shadcn-hooks

A decision and implementation guide for shadcn-hooks in React projects. It helps developers match requirements to hooks across state, lifecycle, and browser tasks, while noting when external dependencies are required.

Key features

  1. 01Match requirements to suitable hooks
  2. 02Guide hook invocation patterns
  3. 03Cover state and lifecycle management
  4. 04Provide browser-focused hooks
  5. 05Specify conditions for external dependencies

Use cases

  1. 01Choose hooks for React features
  2. 02Implement debounce or throttle behavior
  3. 03Track browser state and events
  4. 04Check whether external data hooks apply

Install

Copy the command and run it in a terminal.

$npx skills add https://github.com/debbl/shadcn-hooks --skill shadcn-hooks

After installing, type/shadcn-hooksin Claude Code to confirm it loaded.

Bundled files

References and scripts installed along with SKILL.md.

references/
useActiveElement.md
useBattery.md
useBoolean.md
useClickAnyWhere.md
useClickAway.md
useClipboard.md
useControllableValue.md
useCounter.md
useCreation.md
useCustomCompareEffect.md
useDebounce.md
useDebounceEffect.md
useDebounceFn.md
useDeepCompareEffect.md
useDeepCompareLayoutEffect.md
useDocumentVisibility.md
useEffectEvent.md
useEffectWithTarget.md
useElementSize.md
useEventListener.md
useFps.md
useFullscreen.md
useHash.md
useHover.md
useInterval.md
useInViewport.md
useIsHydrated.md
useIsMatchMedia.md
useIsomorphicLayoutEffect.md
useIsOnline.md

Details

From the project README

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):

# Install a single hook (recommended)
npx shadcn@latest add @shadcnhooks/use-boolean

# Install multiple hooks at once
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
FunctionDescriptionInvocation
useBooleanBoolean state with set, setTrue, setFalse, toggle helpersAUTO
useControllableValueSupports both controlled and uncontrolled component patternsAUTO
useCounterCounter with inc, dec, set, reset helpersAUTO
useDebounceDebounced reactive valueAUTO
useResetStateState with a reset function to restore the initial valueAUTO
useThrottleThrottled reactive valueAUTO
useToggleToggle between two values with utility actionsAUTO
Advanced
FunctionDescriptionInvocation
useCreationMemoized factory with deep dependency comparisonAUTO
useCustomCompareEffectuseEffect with a custom dependency comparatorAUTO
useLatestRef that always holds the latest valueAUTO
useLockFnPrevents concurrent execution of an async functionAUTO
useMemoizedFnStable function reference that never changes identityAUTO
usePreviousReturns the previous value of a stateAUTO
Lifecycle
FunctionDescriptionInvocation
useDebounceEffectDebounced useEffectAUTO
useDebounceFnDebounced function with run, cancel, flush controlsAUTO
useDeepCompareEffectuseEffect with deep dependency comparisonAUTO
useDeepCompareLayoutEffectuseLayoutEffect with deep dependency comparisonAUTO
useEffectEventPonyfill for React 19's useEffectEventAUTO
useEffectWithTargetuseEffect that supports target DOM element(s) as dependenciesAUTO
useIntervalInterval timer with auto-cleanupAUTO
useIsHydratedReturns true after client hydration completesAUTO
useIsomorphicLayoutEffectuseLayoutEffect on client, useEffect on serverAUTO
useMountRuns a callback only on component mountAUTO
useThrottleEffectThrottled useEffectAUTO
useThrottleFnThrottled function with run, cancel, flush controlsAUTO
useTimeoutTimeout timer with auto-cleanupAUTO
useUnmountRuns cleanup on component unmountAUTO
useUpdateReturns a function that forces component re-renderAUTO
useUpdateEffectuseEffect that skips the first renderAUTO
Browser
FunctionDescriptionInvocation
useActiveElementTrack the currently focused elementAUTO
useBatteryReactive battery level and charging informationAUTO
useClickAnyWhereListen to click events anywhere on the documentAUTO
useClickAwayDetect clicks outside of target element(s)AUTO
useClipboardReactive Clipboard API with read/write supportAUTO
useDocumentVisibilityReactive document visibility stateAUTO
useElementSizeReactive element size via ResizeObserverAUTO
useEventListenerDeclarative event listener with auto-cleanupAUTO
useFpsReactive FPS (frames per second) measurementAUTO
useFullscreenReactive Fullscreen APIAUTO
useHashReactive window.location.hashAUTO
useHoverReactive hover state of an elementAUTO
useInViewportTrack element visibility via IntersectionObserverAUTO
useIsMatchMediaReactive CSS media query matchingAUTO
useIsOnlineReactive online/offline network statusAUTO
useMouseReactive pointer coordinates for mouse/touchAUTO
useNetworkReactive network connection informationAUTO
useOsReactive browser operating system detectionAUTO
useScrollLockLock/unlock scroll on a target elementAUTO
useTextSelectionReactive text selection state with bounding rectAUTO
useTitleReactive document title managementAUTO
Dev
FunctionDescriptionInvocation
useWhyDidYouUpdateLogs which props changed between renders (debug only)AUTO
External
FunctionDescriptionInvocation
useMcpModel Context Protocol client hook from use-mcpEXTERNAL
useQueryData fetching hook from @tanstack/react-queryEXTERNAL
useStickToBottomScroll-stick behavior from use-stick-to-bottomEXTERNAL
useSWRData fetching hook from swrEXTERNAL

Comments

Markdown supported