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

@sandeep-jaiswar/hooks

v0.0.6

Published

A collection of highly useful and reusable React hooks that enhance the development experience with features like long press handling, media query detection, state management, and more.

Readme

@sandeep-jaiswar/hooks

A collection of highly useful and reusable React hooks that enhance the development experience with features like long press handling, media query detection, state management, and more.

This package is designed to provide a set of flexible hooks to help manage common UI and state-related functionality in your React applications. It is optimized for performance and supports both mouse and touch events.

Installation

You can install the package via npm or yarn:

npm

npm install @sandeep-jaiswar/hooks

yarn

yarn add @sandeep-jaiswar/hooks

Bun

bun add @sandeep-jaiswar/hooks

Available Hooks

Here is a list of hooks currently available in @sandeep-jaiswar/hooks:

useLongPress

A hook to handle long press interactions for both mouse and touch events.

Usage

import { useLongPress } from '@sandeep-jaiswar/hooks';

const Component = () => {
  const [ref, isPressed] = useLongPress({
    onLongPress: () => console.log('Long press triggered'),
    onPress: () => console.log('Short press triggered'),
    threshold: 700, // Optional, default is 500ms
  });

  return <button ref={ref}>Press Me</button>;
};

useMediaQuery

Detects whether the current screen matches a given media query.

Usage

import { useMediaQuery } from '@sandeep-jaiswar/hooks';

const Component = () => {
  const isMobile = useMediaQuery('(max-width: 768px)');
  
  return (
    <div>
      {isMobile ? 'Mobile View' : 'Desktop View'}
    </div>
  );
};

useHover

Detects if an element is hovered or not.

Usage

import { useHover } from '@sandeep-jaiswar/hooks';

const Component = () => {
  const [ref, isHovered] = useHover();

  return <div ref={ref}>{isHovered ? 'Hovered' : 'Not Hovered'}</div>;
};

usePrevious

Stores the previous value of a state or prop.

Usage

import { usePrevious } from '@sandeep-jaiswar/hooks';

const Component = () => {
  const [count, setCount] = useState(0);
  const prevCount = usePrevious(count);

  return (
    <div>
      <p>Current Count: {count}</p>
      <p>Previous Count: {prevCount}</p>
      <button onClick={() => setCount(count + 1)}>Increment</button>
    </div>
  );
};

useBattery

Detects the battery status of the device.

Usage

import { useBattery } from '@sandeep-jaiswar/hooks';

const Component = () => {
  const battery = useBattery();

  return (
    <div>
      {battery ? (
        <p>Battery Level: {battery.level}%</p>
      ) : (
        <p>Battery status not available</p>
      )}
    </div>
  );
};

useIdle

Detects whether the user is idle or active.

Usage

import { useIdle } from '@sandeep-jaiswar/hooks';

const Component = () => {
  const isIdle = useIdle(5000); // Trigger idle state after 5 seconds of inactivity
  
  return <div>{isIdle ? 'User is idle' : 'User is active'}</div>;
};

Development

If you want to contribute to this project, follow these steps to set up the development environment:

  1. Clone the repository:
git clone https://github.com/sandeep-jaiswar/hooks.git
  1. Install dependencies:
bun install
  1. Run the development server:
bun run dev
  1. Build the package:
bun run build
  1. Test the hooks:
bun run test

Contributing

Contributions are welcome! Feel free to open an issue or submit a pull request with any improvements, bug fixes, or new hooks.

  1. Fork the repository
  2. Create a new branch
  3. Make your changes
  4. Open a pull request

License

This project is licensed under the MIT License - see the LICENSE file for details.


Acknowledgements

  • This repository is maintained by Sandeep Jaiswar.
  • Thanks to all contributors to the React ecosystem for making these hooks possible!