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

use-re-hooks

v2.1.2

Published

React custom hooks library

Downloads

43

Readme

Use-Re-Hooks

CI Publish npm version npm downloads

"Potentially" Useful React hooks!

Installation

npm install use-re-hooks
yarn add use-re-hooks

Module Formats

This package ships both ESM and CommonJS entrypoints.

Use import in ESM projects, TypeScript projects, and modern bundlers:

import { useDebounce, useTimeout } from "use-re-hooks";

Use require in CommonJS projects:

const { useDebounce, useTimeout } = require("use-re-hooks");

Package entrypoints:

  • import resolves to dist/index.js
  • require resolves to dist/index.cjs
  • Type declarations resolve to dist/index.d.ts

Usage

import { useDebounce } from "use-re-hooks";

function Search() {
  const [query, setQuery] = useState("");
  const debouncedQuery = useDebounce(query, 300);

  return <input value={debouncedQuery} onChange={(event) => setQuery(event.target.value)} />;
}

Hooks

useCase

Converts strings between camelCase and snake_case.

Demo: playground/src/hooks/useCase.demo.tsx

const { toCamelCase, toSnakeCase } = useCase();

useClipboard

Writes text or image data to the system clipboard.

Demo: playground/src/hooks/useClipboard.demo.tsx

const { addToClipboard } = useClipboard();
await addToClipboard({ text: "Copied text" });

useColor

Generates random colors and converts between hex and RGB formats.

Demo: playground/src/hooks/useColor.demo.tsx

const { getRandomColor, fadeColor, hexToRgb, rgbToHex } = useColor();

useCompose

Composes functions from right to left and returns the computed result.

Demo: playground/src/hooks/useCompose.demo.tsx

const { result } = useCompose<number>([(value) => (value ?? 0) + 1, () => 10]);

useDebounce

Returns a debounced version of a value after a delay.

Demo: playground/src/hooks/useDebounce.demo.tsx

const debouncedValue = useDebounce(value, 300);

useEllipsis

Shortens text from the start, middle, or end using configurable ellipsis rules.

Demo: playground/src/hooks/useEllipsis.demo.tsx

const { ellipsis } = useEllipsis({ length: 12 });

useFile

Reads the first selected file from a file input as text.

Demo: playground/src/hooks/useFile.demo.tsx

const inputRef = useRef<HTMLInputElement>(null);
useFile(inputRef, (text) => console.log(text));

useGeolocation

Requests the user's current location and exposes the request status.

Demo: playground/src/hooks/useGeolocation.demo.tsx

const { STATUS } = useGeolocation({
  success: (position) => console.log(position.coords.latitude),
});

useIsVisible

Tracks whether an element is visible within the viewport or a scroll container.

Demo: playground/src/hooks/useIsVisible.demo.tsx

const [ref, isVisible] = useIsVisible({ threshold: 0.5 });

useMeasurePerformance

Measures how long synchronous functions take to execute.

Demo: playground/src/hooks/useMeasurePerformance.demo.tsx

const { results, measure } = useMeasurePerformance({
  entries: [{ name: "task", func: () => heavyWork() }],
});

useNotification

Requests browser notification permission and sends notifications.

Demo: playground/src/hooks/useNotification.demo.tsx

const { status, notify } = useNotification();
notify({ title: "Saved", body: "Changes saved." });

usePipe

Pipes functions from left to right and returns the computed result.

Demo: playground/src/hooks/usePipe.demo.tsx

const { result } = usePipe<number>([() => 10, (value) => (value ?? 0) + 2]);

useRandomNumber

Generates a random integer within an inclusive range.

Demo: playground/src/hooks/useRandomNumber.demo.tsx

const { value } = useRandomNumber({ min: 1, max: 6 });

useSlugify

Creates URL-friendly slugs and stores generated values by input text.

Demo: playground/src/hooks/useSlugify.demo.tsx

const { slugify, slugs } = useSlugify();

useTimeout

Schedules a one-shot callback after a delay while enabled.

Demo: playground/src/hooks/useTimeout.demo.tsx

useTimeout(() => {
  console.log("done");
}, 1000, true);

useWebWorker

Creates a Web Worker from a function and exposes helpers for messaging and status.

Demo: playground/src/hooks/useWebWorker.demo.tsx

const { postMessage, result, status } = useWebWorker<number, number>(() => {
  self.onmessage = (event) => {
    self.postMessage(event.data * 2);
  };
});