npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

rooks

v9.5.0

Published

Collection of awesome react hooks

Readme

CI and Semantic Release GitHub release (latest by date) GitHub Codecov branch

npm npm bundle size Module node-lts

GitHub contributors Website GitHub stars

📚 Table of Contents

🚀 Quick Start

Get up and running in seconds:

npm install rooks
# or
yarn add rooks
# or
pnpm add rooks

Import any hook and start using it:

import { useDidMount, useCounter, useToggle } from "rooks";

function App() {
  const { value, increment, decrement } = useCounter(0);
  const [isOn, toggleIsOn] = useToggle(false);

  useDidMount(() => {
    console.log("Component mounted! 🎉");
  });

  return (
    <div>
      <h1>Count: {value}</h1>
      <button onClick={increment}>Increment</button>
      <button onClick={decrement}>Decrement</button>

      <h2>Toggle is {isOn ? "ON" : "OFF"}</h2>
      <button onClick={toggleIsOn}>Toggle</button>
    </div>
  );
}

📖 Browse all hooks🎮 Try in CodeSandbox

✨ Why Rooks?

🌟 Popular Hooks

State Management

Event Handling

Lifecycle & Effects

List of all hooks

  • useAnimation - Animation hook for React
  • useEasing - A hook for creating controlled easing animations with start/stop/reset capabilities.
  • useIntervalWhen - Sets an interval immediately when a condition is true
  • useLockBodyScroll - This hook locks the scroll of the body element when isLocked is set to true.
  • usePrefersReducedMotion - A React hook that returns true if the user has enabled the 'prefers-reduced-motion' setting in their system.
  • useRaf - A continuously running requestAnimationFrame hook for React
  • useResizeObserverRef - Resize Observer hook for React.
  • useSpring - Spring animation hook for React
  • useTimeoutWhen - Takes a callback and fires it when a condition is true
  • useTween - Tween animation hook for React
  • useCheckboxInputState - Simple checkbox state management hook that provides a boolean state and props that can be spread directly onto a checkbox input element
  • useFileDropRef - Drop files easily
  • useFormState - Comprehensive form state management with validation
  • useInput - Input hook for React.
  • useKey - keypress, keyup and keydown event handlers as hooks for react.
  • useKeyBindings - useKeyBindings can bind multiple keys to multiple callbacks and fire the callbacks on key press.
  • useKeyRef - Very similar useKey but it returns a ref
  • useKeys - A hook which allows to setup callbacks when a combination of keys are pressed at the same time.
  • useAsyncEffect - A version of useEffect that accepts an async function
  • useDebouncedAsyncEffect - A version of useEffect that accepts an async function and debounces its execution based on dependency changes
  • useDebouncedEffect - A version of useEffect that debounces the effect execution based on dependency changes
  • useDeepCompareEffect - Deep compare dependencies instead of shallow for useEffect
  • useDidMount - componentDidMount hook for React
  • useDidUpdate - componentDidUpdate hook for react
  • useDocumentTitle - A hook to easily update document title with React
  • useEffectOnceWhen - Runs a callback effect atmost one time when a condition becomes true
  • useIsomorphicEffect - A hook that resolves to useEffect on the server and useLayoutEffect on the client.
  • useLifecycleLogger - A react hook that console logs parameters as component transitions through lifecycles.
  • useWillUnmount - componentWillUnmount lifecycle as hook for React.
  • useTimeTravelState - A hook that manages state which can undo and redo. A more powerful version of useUndoState hook.
  • useToggle - Toggle (between booleans or custom data)hook for React.
  • useUndoRedoState - Setstate but can also undo and redo
  • useUndoState - Drop in replacement for useState hook but with undo functionality.
  • useEventListenerRef - A react hook to add an event listener to a ref
  • useForkRef - A hook that can combine two refs(mutable or callbackRefs) into a single callbackRef
  • useFreshCallback - Avoid stale closures and keep your callback fresh
  • useFreshRef - Avoid stale state in callbacks with this hook. Auto updates values using a ref.
  • useFreshTick - Like use-fresh-ref but specifically for functions
  • useMergeRefs - Merges any number of refs into a single ref
  • useRefElement - Helps bridge gap between callback ref and state

Features

✅ Collection of 120 hooks as standalone modules.

✅ Standalone package with all the hooks at one place

✅ CommonJS, UMD and ESM Support

Installation

npm i -s rooks

Import any hook from "rooks" and start using them!

import { useDidMount } from "rooks";

Usage

function App() {
  useDidMount(() => {
    alert("mounted");
  });
  return (
    <div className="App">
      <h1>Hello CodeSandbox</h1>
      <h2>Start editing to see some magic happen!</h2>
    </div>
  );
}

Standalone Package

Package containing all the hooks is over here. - Docs and Npm Install

License

MIT

Contributors ✨

All Contributors

Thanks goes to these wonderful people (emoji key):