imbhargav5/rooks

Over 800 k monthly downloads. Collection of awesome react hooks

TypeScript

3,454

3,422 commits

updated Oct 4, 2026

See the code

README

Rooks: a collection of React hooks

CI npm version npm monthly downloads bundle size coverage license

Rooks

Focused, tree-shakeable, TypeScript-first React hooks for application state, browser APIs, events, timing, and UI behavior.

Documentation · Getting started · Hook reference · Contributing

Install

pnpm add rooks

Rooks supports React and React DOM 18 or 19. The package is ESM-only.

Quick start

import { useCounter } from "rooks";

export function Counter() {
  const { value, increment, decrement, reset } = useCounter(0);

  return (
    <section>
      <p>Count: {value}</p>
      <button type="button" onClick={decrement}>
        Decrement
      </button>
      <button type="button" onClick={increment}>
        Increment
      </button>
      <button type="button" onClick={reset}>
        Reset
      </button>
    </section>
  );
}

Continue with the three-step tutorial, or browse the hook index.

Entrypoints

Rooks separates stable hooks, experimental hooks, and Temporal hooks so applications only opt into the compatibility and dependency surface they need.

Import pathUse it forStability
rooksStable hooks and explicitly exported utility typesStable
rooks/experimentalHooks whose API or behavior may change between minor releasesExperimental
rooks/temporalHooks built on the JavaScript Temporal APIStable, optional polyfill required where Temporal is unavailable

Stable hooks

import { useToggle } from "rooks";

Only types exported by an entrypoint are importable. Option and result shapes shown inline in a hook page are not necessarily public named exports.

Experimental hooks

import { useWebSocket } from "rooks/experimental";

Experimental hooks are isolated from the main entrypoint and can change in a minor release. Read the experimental hooks guide before using them in production.

Temporal hooks

Install the optional polyfill when your supported runtimes do not provide Temporal:

pnpm add @js-temporal/polyfill
import { useTemporalNow } from "rooks/temporal";

export function Clock() {
  const now = useTemporalNow({ precision: "second" });

  return <time>{now?.toString() ?? "Loading time…"}</time>;
}

Temporal hooks require BigInt support and have specific SSR and time-zone considerations. See the Temporal hooks guide.

Server rendering and browser APIs

Hooks that read browser globals handle server rendering in hook-specific ways. Components still need a client boundary in frameworks where hooks cannot run in server components, and permission-gated APIs need a fallback for unsupported or denied states.

Read SSR and browser APIs before using browser-only hooks in a server-rendered application.

Hook catalog

The following counts and tables are generated from the package export barrels and the canonical MDX pages. Run pnpm docs:generate after adding or moving a public hook; CI verifies the zone with pnpm docs:generate --check.

147 canonical hook implementations are available across three entrypoints. Aliases are listed separately and do not inflate this count.

EntrypointCanonical hooks
rooks118
rooks/experimental25
rooks/temporal4
Animation & Timing (10)
HookDescriptionEntrypoint
useAnimationDeprecated progress animation hook; use useEasing for new code.rooks
useEasingCreates a controllable eased animation progress value.rooks
useIntervalWhenRuns the latest callback on an interval while a condition is true.rooks
useLockBodyScrollSets document.body overflow to hidden while a condition is true.rooks
usePrefersReducedMotionTracks the user's prefers-reduced-motion media setting.rooks
useRafRuns the latest callback every animation frame while active.rooks
useResizeObserverRefObserves the size of the element attached to a callback ref.rooks
useSpringAnimates a number toward a target with a basic damped spring simulation.rooks
useTimeoutWhenRuns the latest callback once after a delay while a condition remains true.rooks
useTweenAnimates an eased progress value from zero to one.rooks
Browser APIs (16)
HookDescriptionEntrypoint
useBroadcastChannelEnables cross-tab/window communication via the BroadcastChannel API.rooks
useClipboardReads from and writes to the clipboard using the Clipboard API.rooks
useFetchHook for fetching data from URLs with loading states, error handling, and automatic JSON parsingrooks
useGeolocationTracks the user's geographic location using the Geolocation API.rooks
useIdleDetectionApiDetects when the user is idle using the IdleDetection API.rooks
useMediaRecorderRecords audio/video streams using the MediaRecorder API.rooks
useNavigatorLanguageReturns the user's preferred language from the Navigator API.rooks
useNetworkInformationExposes network connectivity and speed information from the Network Information API.rooks
useNotificationRequests permission and sends desktop notifications via the Notifications API.rooks
useOnlineTracks the browser's navigator.onLine connectivity hint.rooks
useOrientationReturns the current screen orientation and listens for orientation changes.rooks
useScreenDetailsApiProvides details about the user's screens using the Screen Details API.rooks
useShareTriggers the native Web Share dialog to share content from the browser.rooks
useSpeechConverts text to speech using the Web Speech API.rooks
useVibrateTriggers device vibration patterns using the Vibration API.rooks
useWebLocksApiCoordinates asynchronous resource access using the Web Locks API.rooks
Development & Debugging (2)
HookDescriptionEntrypoint
useRenderCountCounts how many times the current hook instance has rendered.rooks
useWhyDidYouUpdateLogs tracked values whose identity changed between committed renders.rooks
Event Handling (17)
HookDescriptionEntrypoint
useDocumentEventListenerAttaches a document event listener and removes it when the component unmounts.rooks
useDocumentVisibilityStateReturns the document visibility state and updates when it changes.rooks
useFocusProvides focus and blur props for an element's own focus boundary.rooks
useFocusWithinProvides focus props that track entry to and exit from an element subtree.rooks
useIsDroppingFilesReports whether files are being dragged over an element or the window.rooks
useOnClickRefReturns a ref that handles native click and touch-end events.rooks
useOnHoverRefReturns a ref that handles native mouse-enter and mouse-leave events.rooks
useOnLongHoverCalls a callback after an element remains hovered for a duration.rooks
useOnLongPressCalls a callback after an element remains pressed for a duration.rooks
useOnStartTypingCalls a callback for allowed typing keys outside editable elements.rooks
useOnWindowResizeCalls a callback for passive window resize events.rooks
useOnWindowScrollCalls a callback for passive window scroll events.rooks
useOutsideClickCalls a handler for click or touch-start events outside an object ref.rooks
useOutsideClickRefReturns a ref and calls a handler for click or touch-start events outside it.rooks
usePageLeaveCalls a callback for unload, page-hide, and hidden-document signals.rooks
useTextSelectionReturns the current text selection for the document or a target element.rooks
useWindowEventListenerAttaches a window event listener and removes it when the component unmounts.rooks
Experimental Hooks (25)
HookDescriptionEntrypoint
useAsyncDisposableManages async disposable resources using the TC39 Explicit Resource Management proposal.rooks/experimental
useBeforeUnloadPrompt before the page unloads when a guard passes.rooks/experimental
useBrowserCookieStatePersist React state in browser cookies with same-document synchronization.rooks/experimental
useDisposableManages synchronous disposable resources using the TC39 Explicit Resource Management proposal.rooks/experimental
useEventListenerStrongly typed event-listener primitive for browser EventTargets.rooks/experimental
useIsClientTell whether the component has mounted on the client.rooks/experimental
useKeyPressTrack whether one or more keyboard keys are currently pressed.rooks/experimental
useLocationHashRead the current location hash, including the leading #.rooks/experimental
useLocationSearchParamRead the first value for a specific search parameter.rooks/experimental
useLocationSnapshotRead the current browser location as a stable snapshot.rooks/experimental
useMediaDevicesEnumerate and refresh available media input and output devices.rooks/experimental
usePermissionQuery and optionally watch browser permission state.rooks/experimental
useRequestGeneric promise-request lifecycle hook with retries, polling, and mutation.rooks/experimental
useResponsiveTrack a named set of media queries and compute the current breakpoint.rooks/experimental
useScriptLoad and share external script state across multiple consumers.rooks/experimental
useScrollTrack an element's scroll offsets and scrollable bounds.rooks/experimental
useSizeMeasure an element with ResizeObserver using a callback ref.rooks/experimental
useSuspenseFaviconLoads a favicon and suspends the component until the resource is ready.rooks/experimental
useSuspenseIndexedDBStateReads and writes IndexedDB state with Suspense support.rooks/experimental
useSuspenseLocalStorageStateReads and writes localStorage state with Suspense support.rooks/experimental
useSuspenseNavigatorBatteryReads battery status from the Battery API with Suspense support.rooks/experimental
useSuspenseNavigatorUserAgentDataReads User-Agent Client Hints with Suspense support.rooks/experimental
useSuspenseSessionStorageStateReads and writes sessionStorage state with Suspense support.rooks/experimental
useVirtualListRender a fixed-size virtual list with ready-to-use item styles.rooks/experimental
useWebSocketManage a WebSocket connection with parsing, sending, and reconnection helpers.rooks/experimental
Form & File Handling (3)
HookDescriptionEntrypoint
useCheckboxInputStateReturns controlled checkbox state, handlers, and input props.rooks
useFileDropRefReturns a ref that validates dropped files and reports accepted and rejected files.rooks
useFormStateManages named form values, validation, touched state, and submission.rooks
Keyboard & Input (5)
HookDescriptionEntrypoint
useInputReturns controlled input value and change props with optional validation.rooks
useKeyCalls a callback when any configured keyboard identifier matches an event.rooks
useKeyBindingsMaps independent keyboard identifiers to their callbacks.rooks
useKeyRefReturns a callback ref that handles matching keyboard events on an element.rooks
useKeysCalls a callback when every key in a configured combination is pressed.rooks
Lifecycle & Effects (11)
HookDescriptionEntrypoint
useAsyncEffectRuns asynchronous effect work with a current-generation guard and optional cleanup.rooks
useDebouncedAsyncEffectStarts only the latest asynchronous effect after a debounce window.rooks
useDebouncedEffectDelays an effect until its dependencies stop changing.rooks
useDeepCompareEffectRuns an effect when a dependency array changes by deep equality.rooks
useDidMountRuns a callback from an effect when a component mounts.rooks
useDidUpdateRuns a callback after updates while skipping the initial mount.rooks
useDocumentTitleUpdates document.title and can restore its original value during cleanup.rooks
useEffectOnceWhenRuns the latest callback once when a condition first becomes true.rooks
useIsomorphicEffectUses a layout effect in the browser and a passive effect during server rendering.rooks
useLifecycleLoggerLogs a component's mount, update, and unmount lifecycle to the console.rooks
useWillUnmountRuns the initial callback as an effect cleanup when a component unmounts.rooks
Mouse & Touch (3)
HookDescriptionEntrypoint
useMouseReturns document-level mouse coordinates from the latest mousemove event.rooks
useMouseMoveDeltaReturns movement and velocity between consecutive document mousemove events.rooks
useMouseWheelDeltaReturns vertical wheel delta and velocity from document wheel events.rooks
Performance & Optimization (5)
HookDescriptionEntrypoint
useDebounceReturns a stable Lodash-style debounced wrapper around the latest callback.rooks
useDebouncedValueReturns a value that follows its input after a delay, plus an immediate setter.rooks
useDebounceFnDebounces a callback and reports whether its timeout window is active.rooks
useThrottleExecutes a callback immediately at most once per timeout window.rooks
useWebWorkerCreates and manages a classic Web Worker with message, status, and error state.rooks
State Management (19)
HookDescriptionEntrypoint
useArrayStateManages an array state with helper methods for push, pop, splice, sort, and more.rooks
useCountdownCounts the intervals remaining until a target Date and reports progress or completion.rooks
useCounterManages a numeric counter with increment, decrement, and reset operations.rooks
useGetIsMountedReturns a function that reports whether the component is currently mounted.rooks
useLocalstorageStatePersists React state in localStorage and synchronizes matching hook instances.rooks
useMapStateManages a record-like object as React state with keyed update and removal helpers.rooks
useMultiSelectableListManages multiple-selection list state with toggle and select-all helpers.rooks
useNativeMapStateManages a native Map object in React state with reactive update helpers.rooks
usePreviousDifferentReturns the most recent previous value that was different from the current one.rooks
usePreviousImmediateReturns the previous value of a variable immediately after it changes.rooks
usePromiseTracks the status and result of a Promise (pending, resolved, or rejected).rooks
useQueueStateManages queue (FIFO) state with enqueue, dequeue, and peek operations.rooks
useRafStateUpdates React state on each requestAnimationFrame tick.rooks
useSafeSetStateCalls setState only if the component is still mounted, preventing memory leaks.rooks
useSelectManages a selection state from a list of options with helpers.rooks
useSelectableListManages a single-selection list state with toggle and clear helpers.rooks
useSessionstorageStatePersists React state in sessionStorage and synchronizes matching hook instances.rooks
useSetStateManages a Set data structure as React state with add, delete, and clear helpers.rooks
useStackStateManages stack (LIFO) state with push, pop, and peek operations.rooks
State History & Time Travel (4)
HookDescriptionEntrypoint
useTimeTravelStateManages state with undo, redo, and navigation across its complete history.rooks
useToggleToggles a boolean or applies a custom reducer to another state type.rooks
useUndoRedoStateManages state with bounded undo and redo history.rooks
useUndoStateManages state with a bounded, one-directional undo history.rooks
Temporal Hooks (4)
HookDescriptionEntrypoint
useTemporalAgeCalculates calendar age from a date and updates at each local day boundary.rooks/temporal
useTemporalCountdownCounts down to a Temporal instant and stops when the target is reached.rooks/temporal
useTemporalElapsedMeasures elapsed time from an instant and updates on aligned boundaries.rooks/temporal
useTemporalNowReturns the current time as a Temporal value and updates on aligned time boundaries.rooks/temporal
UI & Layout (14)
HookDescriptionEntrypoint
useAudioControls an audio element while exposing playback, loading, timing, volume, rate, loop, and error state.rooks
useBoundingclientrectReads an element's DOMRect after mount and whenever the observed DOM subtree mutates.rooks
useBoundingclientrectRefSupplies a callback ref, its current DOMRect, and a manual measurement function.rooks
useDimensionsRefMeasures an attached div after layout and optionally on window resize and scroll.rooks
useFullscreenEnters, exits, and tracks Fullscreen API state for the document or a target element.rooks
useIntersectionObserverRefReturns a callback ref that forwards IntersectionObserver notifications to the latest callback.rooks
useInViewRefReturns a callback ref and whether its element currently intersects an observer root.rooks
useMeasureMeasures client, offset, and scroll dimensions with ResizeObserver and optional debouncing.rooks
useMediaMatchSubscribes to a CSS media query with a deterministic server-rendered fallback.rooks
useMutationObserverObserves mutations on the element in an existing object ref and cleans up automatically.rooks
useMutationObserverRefReturns a callback ref that observes DOM mutations on its current element.rooks
usePictureInPictureApiDetects, enters, exits, and tracks standard Picture-in-Picture state for a video element.rooks
usePreferredColorSchemeTracks the user's light, dark, or no-preference color-scheme media setting.rooks
useVideoSupplies a video ref with playback, timing, mute, volume, seeking, and fullscreen controls.rooks
Utilities & Refs (7)
HookDescriptionEntrypoint
useEventListenerRefReturns a callback ref that manages an event listener on its current HTML element.rooks
useForkRefSends one ref value to two mutable or callback refs.rooks
useFreshCallbackReturns a stable function that delegates to the latest callback after effects run.rooks
useFreshRefKeeps the latest committed value in a stable mutable ref.rooks
useFreshTickReturns a function that invokes the latest void callback after effects run.rooks
useMergeRefsSends one ref value to any number of mutable or callback refs.rooks
useRefElementExposes a callback ref together with the element currently attached to it.rooks
Window & Viewport (2)
HookDescriptionEntrypoint
useWindowScrollPositionReturns reactive horizontal and vertical window scroll coordinates.rooks
useWindowSizeReturns reactive inner and outer browser window dimensions.rooks

Supported aliases

AliasCanonical hookEntrypoint
useObjectStateuseMapStaterooks
useOnLongHoverRefuseOnLongHoverrooks
useOnLongPressRefuseOnLongPressrooks

Documentation

Every hook page is hand-authored MDX under apps/website/content/docs. Import paths, aliases, status, signatures, and README catalog data are validated against the package barrels.

Community

License

Rooks is available under the MIT License.

Contributors

View the current contributor graph.

Thanks to everyone who has contributed to Rooks. The historical acknowledgements below use the All Contributors emoji key; the contributor graph above is the current record.

View historical acknowledgements

hook
hooks
react
react-hook
react-hooks
reactjs
rooks
typescript

imbhargav5/rooks

Over 800 k monthly downloads. Collection of awesome react hooks

TypeScript

3,454

3,422 commits

updated Oct 4, 2026

See the code

README

Rooks: a collection of React hooks

CI npm version npm monthly downloads bundle size coverage license

Rooks

Focused, tree-shakeable, TypeScript-first React hooks for application state, browser APIs, events, timing, and UI behavior.

Documentation · Getting started · Hook reference · Contributing

Install

pnpm add rooks

Rooks supports React and React DOM 18 or 19. The package is ESM-only.

Quick start

import { useCounter } from "rooks";

export function Counter() {
  const { value, increment, decrement, reset } = useCounter(0);

  return (
    <section>
      <p>Count: {value}</p>
      <button type="button" onClick={decrement}>
        Decrement
      </button>
      <button type="button" onClick={increment}>
        Increment
      </button>
      <button type="button" onClick={reset}>
        Reset
      </button>
    </section>
  );
}

Continue with the three-step tutorial, or browse the hook index.

Entrypoints

Rooks separates stable hooks, experimental hooks, and Temporal hooks so applications only opt into the compatibility and dependency surface they need.

Import pathUse it forStability
rooksStable hooks and explicitly exported utility typesStable
rooks/experimentalHooks whose API or behavior may change between minor releasesExperimental
rooks/temporalHooks built on the JavaScript Temporal APIStable, optional polyfill required where Temporal is unavailable

Stable hooks

import { useToggle } from "rooks";

Only types exported by an entrypoint are importable. Option and result shapes shown inline in a hook page are not necessarily public named exports.

Experimental hooks

import { useWebSocket } from "rooks/experimental";

Experimental hooks are isolated from the main entrypoint and can change in a minor release. Read the experimental hooks guide before using them in production.

Temporal hooks

Install the optional polyfill when your supported runtimes do not provide Temporal:

pnpm add @js-temporal/polyfill
import { useTemporalNow } from "rooks/temporal";

export function Clock() {
  const now = useTemporalNow({ precision: "second" });

  return <time>{now?.toString() ?? "Loading time…"}</time>;
}

Temporal hooks require BigInt support and have specific SSR and time-zone considerations. See the Temporal hooks guide.

Server rendering and browser APIs

Hooks that read browser globals handle server rendering in hook-specific ways. Components still need a client boundary in frameworks where hooks cannot run in server components, and permission-gated APIs need a fallback for unsupported or denied states.

Read SSR and browser APIs before using browser-only hooks in a server-rendered application.

Hook catalog

The following counts and tables are generated from the package export barrels and the canonical MDX pages. Run pnpm docs:generate after adding or moving a public hook; CI verifies the zone with pnpm docs:generate --check.

147 canonical hook implementations are available across three entrypoints. Aliases are listed separately and do not inflate this count.

EntrypointCanonical hooks
rooks118
rooks/experimental25
rooks/temporal4
Animation & Timing (10)
HookDescriptionEntrypoint
useAnimationDeprecated progress animation hook; use useEasing for new code.rooks
useEasingCreates a controllable eased animation progress value.rooks
useIntervalWhenRuns the latest callback on an interval while a condition is true.rooks
useLockBodyScrollSets document.body overflow to hidden while a condition is true.rooks
usePrefersReducedMotionTracks the user's prefers-reduced-motion media setting.rooks
useRafRuns the latest callback every animation frame while active.rooks
useResizeObserverRefObserves the size of the element attached to a callback ref.rooks
useSpringAnimates a number toward a target with a basic damped spring simulation.rooks
useTimeoutWhenRuns the latest callback once after a delay while a condition remains true.rooks
useTweenAnimates an eased progress value from zero to one.rooks
Browser APIs (16)
HookDescriptionEntrypoint
useBroadcastChannelEnables cross-tab/window communication via the BroadcastChannel API.rooks
useClipboardReads from and writes to the clipboard using the Clipboard API.rooks
useFetchHook for fetching data from URLs with loading states, error handling, and automatic JSON parsingrooks
useGeolocationTracks the user's geographic location using the Geolocation API.rooks
useIdleDetectionApiDetects when the user is idle using the IdleDetection API.rooks
useMediaRecorderRecords audio/video streams using the MediaRecorder API.rooks
useNavigatorLanguageReturns the user's preferred language from the Navigator API.rooks
useNetworkInformationExposes network connectivity and speed information from the Network Information API.rooks
useNotificationRequests permission and sends desktop notifications via the Notifications API.rooks
useOnlineTracks the browser's navigator.onLine connectivity hint.rooks
useOrientationReturns the current screen orientation and listens for orientation changes.rooks
useScreenDetailsApiProvides details about the user's screens using the Screen Details API.rooks
useShareTriggers the native Web Share dialog to share content from the browser.rooks
useSpeechConverts text to speech using the Web Speech API.rooks
useVibrateTriggers device vibration patterns using the Vibration API.rooks
useWebLocksApiCoordinates asynchronous resource access using the Web Locks API.rooks
Development & Debugging (2)
HookDescriptionEntrypoint
useRenderCountCounts how many times the current hook instance has rendered.rooks
useWhyDidYouUpdateLogs tracked values whose identity changed between committed renders.rooks
Event Handling (17)
HookDescriptionEntrypoint
useDocumentEventListenerAttaches a document event listener and removes it when the component unmounts.rooks
useDocumentVisibilityStateReturns the document visibility state and updates when it changes.rooks
useFocusProvides focus and blur props for an element's own focus boundary.rooks
useFocusWithinProvides focus props that track entry to and exit from an element subtree.rooks
useIsDroppingFilesReports whether files are being dragged over an element or the window.rooks
useOnClickRefReturns a ref that handles native click and touch-end events.rooks
useOnHoverRefReturns a ref that handles native mouse-enter and mouse-leave events.rooks
useOnLongHoverCalls a callback after an element remains hovered for a duration.rooks
useOnLongPressCalls a callback after an element remains pressed for a duration.rooks
useOnStartTypingCalls a callback for allowed typing keys outside editable elements.rooks
useOnWindowResizeCalls a callback for passive window resize events.rooks
useOnWindowScrollCalls a callback for passive window scroll events.rooks
useOutsideClickCalls a handler for click or touch-start events outside an object ref.rooks
useOutsideClickRefReturns a ref and calls a handler for click or touch-start events outside it.rooks
usePageLeaveCalls a callback for unload, page-hide, and hidden-document signals.rooks
useTextSelectionReturns the current text selection for the document or a target element.rooks
useWindowEventListenerAttaches a window event listener and removes it when the component unmounts.rooks
Experimental Hooks (25)
HookDescriptionEntrypoint
useAsyncDisposableManages async disposable resources using the TC39 Explicit Resource Management proposal.rooks/experimental
useBeforeUnloadPrompt before the page unloads when a guard passes.rooks/experimental
useBrowserCookieStatePersist React state in browser cookies with same-document synchronization.rooks/experimental
useDisposableManages synchronous disposable resources using the TC39 Explicit Resource Management proposal.rooks/experimental
useEventListenerStrongly typed event-listener primitive for browser EventTargets.rooks/experimental
useIsClientTell whether the component has mounted on the client.rooks/experimental
useKeyPressTrack whether one or more keyboard keys are currently pressed.rooks/experimental
useLocationHashRead the current location hash, including the leading #.rooks/experimental
useLocationSearchParamRead the first value for a specific search parameter.rooks/experimental
useLocationSnapshotRead the current browser location as a stable snapshot.rooks/experimental
useMediaDevicesEnumerate and refresh available media input and output devices.rooks/experimental
usePermissionQuery and optionally watch browser permission state.rooks/experimental
useRequestGeneric promise-request lifecycle hook with retries, polling, and mutation.rooks/experimental
useResponsiveTrack a named set of media queries and compute the current breakpoint.rooks/experimental
useScriptLoad and share external script state across multiple consumers.rooks/experimental
useScrollTrack an element's scroll offsets and scrollable bounds.rooks/experimental
useSizeMeasure an element with ResizeObserver using a callback ref.rooks/experimental
useSuspenseFaviconLoads a favicon and suspends the component until the resource is ready.rooks/experimental
useSuspenseIndexedDBStateReads and writes IndexedDB state with Suspense support.rooks/experimental
useSuspenseLocalStorageStateReads and writes localStorage state with Suspense support.rooks/experimental
useSuspenseNavigatorBatteryReads battery status from the Battery API with Suspense support.rooks/experimental
useSuspenseNavigatorUserAgentDataReads User-Agent Client Hints with Suspense support.rooks/experimental
useSuspenseSessionStorageStateReads and writes sessionStorage state with Suspense support.rooks/experimental
useVirtualListRender a fixed-size virtual list with ready-to-use item styles.rooks/experimental
useWebSocketManage a WebSocket connection with parsing, sending, and reconnection helpers.rooks/experimental
Form & File Handling (3)
HookDescriptionEntrypoint
useCheckboxInputStateReturns controlled checkbox state, handlers, and input props.rooks
useFileDropRefReturns a ref that validates dropped files and reports accepted and rejected files.rooks
useFormStateManages named form values, validation, touched state, and submission.rooks
Keyboard & Input (5)
HookDescriptionEntrypoint
useInputReturns controlled input value and change props with optional validation.rooks
useKeyCalls a callback when any configured keyboard identifier matches an event.rooks
useKeyBindingsMaps independent keyboard identifiers to their callbacks.rooks
useKeyRefReturns a callback ref that handles matching keyboard events on an element.rooks
useKeysCalls a callback when every key in a configured combination is pressed.rooks
Lifecycle & Effects (11)
HookDescriptionEntrypoint
useAsyncEffectRuns asynchronous effect work with a current-generation guard and optional cleanup.rooks
useDebouncedAsyncEffectStarts only the latest asynchronous effect after a debounce window.rooks
useDebouncedEffectDelays an effect until its dependencies stop changing.rooks
useDeepCompareEffectRuns an effect when a dependency array changes by deep equality.rooks
useDidMountRuns a callback from an effect when a component mounts.rooks
useDidUpdateRuns a callback after updates while skipping the initial mount.rooks
useDocumentTitleUpdates document.title and can restore its original value during cleanup.rooks
useEffectOnceWhenRuns the latest callback once when a condition first becomes true.rooks
useIsomorphicEffectUses a layout effect in the browser and a passive effect during server rendering.rooks
useLifecycleLoggerLogs a component's mount, update, and unmount lifecycle to the console.rooks
useWillUnmountRuns the initial callback as an effect cleanup when a component unmounts.rooks
Mouse & Touch (3)
HookDescriptionEntrypoint
useMouseReturns document-level mouse coordinates from the latest mousemove event.rooks
useMouseMoveDeltaReturns movement and velocity between consecutive document mousemove events.rooks
useMouseWheelDeltaReturns vertical wheel delta and velocity from document wheel events.rooks
Performance & Optimization (5)
HookDescriptionEntrypoint
useDebounceReturns a stable Lodash-style debounced wrapper around the latest callback.rooks
useDebouncedValueReturns a value that follows its input after a delay, plus an immediate setter.rooks
useDebounceFnDebounces a callback and reports whether its timeout window is active.rooks
useThrottleExecutes a callback immediately at most once per timeout window.rooks
useWebWorkerCreates and manages a classic Web Worker with message, status, and error state.rooks
State Management (19)
HookDescriptionEntrypoint
useArrayStateManages an array state with helper methods for push, pop, splice, sort, and more.rooks
useCountdownCounts the intervals remaining until a target Date and reports progress or completion.rooks
useCounterManages a numeric counter with increment, decrement, and reset operations.rooks
useGetIsMountedReturns a function that reports whether the component is currently mounted.rooks
useLocalstorageStatePersists React state in localStorage and synchronizes matching hook instances.rooks
useMapStateManages a record-like object as React state with keyed update and removal helpers.rooks
useMultiSelectableListManages multiple-selection list state with toggle and select-all helpers.rooks
useNativeMapStateManages a native Map object in React state with reactive update helpers.rooks
usePreviousDifferentReturns the most recent previous value that was different from the current one.rooks
usePreviousImmediateReturns the previous value of a variable immediately after it changes.rooks
usePromiseTracks the status and result of a Promise (pending, resolved, or rejected).rooks
useQueueStateManages queue (FIFO) state with enqueue, dequeue, and peek operations.rooks
useRafStateUpdates React state on each requestAnimationFrame tick.rooks
useSafeSetStateCalls setState only if the component is still mounted, preventing memory leaks.rooks
useSelectManages a selection state from a list of options with helpers.rooks
useSelectableListManages a single-selection list state with toggle and clear helpers.rooks
useSessionstorageStatePersists React state in sessionStorage and synchronizes matching hook instances.rooks
useSetStateManages a Set data structure as React state with add, delete, and clear helpers.rooks
useStackStateManages stack (LIFO) state with push, pop, and peek operations.rooks
State History & Time Travel (4)
HookDescriptionEntrypoint
useTimeTravelStateManages state with undo, redo, and navigation across its complete history.rooks
useToggleToggles a boolean or applies a custom reducer to another state type.rooks
useUndoRedoStateManages state with bounded undo and redo history.rooks
useUndoStateManages state with a bounded, one-directional undo history.rooks
Temporal Hooks (4)
HookDescriptionEntrypoint
useTemporalAgeCalculates calendar age from a date and updates at each local day boundary.rooks/temporal
useTemporalCountdownCounts down to a Temporal instant and stops when the target is reached.rooks/temporal
useTemporalElapsedMeasures elapsed time from an instant and updates on aligned boundaries.rooks/temporal
useTemporalNowReturns the current time as a Temporal value and updates on aligned time boundaries.rooks/temporal
UI & Layout (14)
HookDescriptionEntrypoint
useAudioControls an audio element while exposing playback, loading, timing, volume, rate, loop, and error state.rooks
useBoundingclientrectReads an element's DOMRect after mount and whenever the observed DOM subtree mutates.rooks
useBoundingclientrectRefSupplies a callback ref, its current DOMRect, and a manual measurement function.rooks
useDimensionsRefMeasures an attached div after layout and optionally on window resize and scroll.rooks
useFullscreenEnters, exits, and tracks Fullscreen API state for the document or a target element.rooks
useIntersectionObserverRefReturns a callback ref that forwards IntersectionObserver notifications to the latest callback.rooks
useInViewRefReturns a callback ref and whether its element currently intersects an observer root.rooks
useMeasureMeasures client, offset, and scroll dimensions with ResizeObserver and optional debouncing.rooks
useMediaMatchSubscribes to a CSS media query with a deterministic server-rendered fallback.rooks
useMutationObserverObserves mutations on the element in an existing object ref and cleans up automatically.rooks
useMutationObserverRefReturns a callback ref that observes DOM mutations on its current element.rooks
usePictureInPictureApiDetects, enters, exits, and tracks standard Picture-in-Picture state for a video element.rooks
usePreferredColorSchemeTracks the user's light, dark, or no-preference color-scheme media setting.rooks
useVideoSupplies a video ref with playback, timing, mute, volume, seeking, and fullscreen controls.rooks
Utilities & Refs (7)
HookDescriptionEntrypoint
useEventListenerRefReturns a callback ref that manages an event listener on its current HTML element.rooks
useForkRefSends one ref value to two mutable or callback refs.rooks
useFreshCallbackReturns a stable function that delegates to the latest callback after effects run.rooks
useFreshRefKeeps the latest committed value in a stable mutable ref.rooks
useFreshTickReturns a function that invokes the latest void callback after effects run.rooks
useMergeRefsSends one ref value to any number of mutable or callback refs.rooks
useRefElementExposes a callback ref together with the element currently attached to it.rooks
Window & Viewport (2)
HookDescriptionEntrypoint
useWindowScrollPositionReturns reactive horizontal and vertical window scroll coordinates.rooks
useWindowSizeReturns reactive inner and outer browser window dimensions.rooks

Supported aliases

AliasCanonical hookEntrypoint
useObjectStateuseMapStaterooks
useOnLongHoverRefuseOnLongHoverrooks
useOnLongPressRefuseOnLongPressrooks

Documentation

Every hook page is hand-authored MDX under apps/website/content/docs. Import paths, aliases, status, signatures, and README catalog data are validated against the package barrels.

Community

License

Rooks is available under the MIT License.

Contributors

View the current contributor graph.

Thanks to everyone who has contributed to Rooks. The historical acknowledgements below use the All Contributors emoji key; the contributor graph above is the current record.

View historical acknowledgements

hook
hooks
react
react-hook
react-hooks
reactjs
rooks
typescript

Project health

Overall

5.5/10

Maintained

10/10

Code review

1/10
OpenSSF Scorecard

Latest release

9.9.0 · Aug 16, 2026

Releases this year

8

Significant stargazers

Manish R Jain

819 followers · starred Feb 2023

Vitaly

72 followers · starred Aug 2021

Jan Peer Stöcklmair

84 followers · starred Dec 2021

Andrew Joslin

602 followers · starred Dec 2019