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 🙏

© 2025 – Pkg Stats / Ryan Hefner

react-timer-hooks

v0.5.0

Published

A lightweight React hook that provides a fully functional stopwatch with start, pause, resume, and reset controls. Supports optional LocalStorage persistence and real-time catch-up after tab close. Zero dependencies, TypeScript ready, and easy to drop int

Downloads

649

Readme

📋 View Roadmap & Feature Details →

See planned features, release timeline, and contribution guidelines


🏆 Why React Timer Hooks?

Most timer utilities are bloated, poorly typed, or overly complex.
react-timer-hooks solves that with a clean, minimal API built for modern React.


✔ Lightweight & Zero Dependencies

  • Pure React hooks — no unnecessary packages.

✔ Fully Typed with TypeScript

  • Great IntelliSense + fully typed API.
  • JavaScript users can also use it without extra setup.

✔ Modern Bundling

  • Distributed as both ESM and CJS, built using tsup for maximum compatibility across Vite, Next.js, CRA, Webpack, and Node.

✔ Persistence Support

  • Stopwatch and countdown values can survive refresh or tab close using localStorage.

✔ Modular & Tree-Shakable

  • Import only the hooks you need.

✔ Real-World Use Cases

Perfect for workout timers, countdowns, productivity apps, dashboards, quizzes, and more.


🏆 Recommended Hook Bundle

This library includes a complete set of time-related hooks:

  1. useStopwatch
    Start, pause, resume, and reset — with optional persistence and real-time catch-up.
  2. useCountdown
    A reverse timer with optional completion callback.
  3. useInterval
    A safe interval hook that avoids stale closures and handles cleanup correctly.
  4. useTimeout
    A single-run delay hook, cleaned up automatically.
  5. useClock
    A live ticking clock for dashboards or realtime UI.

Together, these hooks create a small yet powerful time utility toolkit for React.


🚀 Why This Library Is the Best Choice

🧩 Full Timer Suite

Most libraries offer only one timer; this one provides a full set of tools.

⚡ Powered by tsup

Tiny output, fast builds, auto typings, and great compatibility.

🧠 Correct React Patterns

No duplicate intervals, no stale closures, predictable cleanup, and stable references.

🗃 Persistence Done Right

Supports both simple localStorage persistence and more advanced real-time elapsed syncing.

❤️ Beginner-Friendly, Production-Ready

Simple APIs for beginners, robust implementations for professional work.


💡 Basic Usage Example

import { useStopwatch } from "react-timer-hooks";

function App() {
  const { seconds, start, pause, reset, isRunning } = useStopwatch(0);

  return (
    <div>
      <h1>{seconds}s</h1>
      {!isRunning ? (
        <button onClick={start}>Start</button>
      ) : (
        <button onClick={pause}>Pause</button>
      )}
      <button onClick={reset}>Reset</button>
    </div>
  );
}

📜 License

MIT License — open for both personal and commercial use.


🙌 Contributions

Contributions, issues, and suggestions are welcome.