Modern, lightweight, dependency-free React hooks for time-based logic.
Stopwatch • Countdown • Interval • Timeout • Clock
See planned features, release timeline, and contribution guidelines
Most timer utilities are bloated, poorly typed, or overly complex.
react-timer-hooks solves that with a clean, minimal API built for modern React.
- Pure React hooks — no unnecessary packages.
- Great IntelliSense + fully typed API.
- JavaScript users can also use it without extra setup.
- Distributed as both ESM and CJS, built using tsup for maximum compatibility across Vite, Next.js, CRA, Webpack, and Node.
- Stopwatch and countdown values can survive refresh or tab close using localStorage.
- Import only the hooks you need.
Perfect for workout timers, countdowns, productivity apps, dashboards, quizzes, and more.
This library includes a complete set of time-related hooks:
- useStopwatch
Start, pause, resume, and reset — with optional persistence and real-time catch-up. - useCountdown
A reverse timer with optional completion callback. - useInterval
A safe interval hook that avoids stale closures and handles cleanup correctly. - useTimeout
A single-run delay hook, cleaned up automatically. - useClock
A live ticking clock for dashboards or realtime UI.
Together, these hooks create a small yet powerful time utility toolkit for React.
Most libraries offer only one timer; this one provides a full set of tools.
Tiny output, fast builds, auto typings, and great compatibility.
No duplicate intervals, no stale closures, predictable cleanup, and stable references.
Supports both simple localStorage persistence and more advanced real-time elapsed syncing.
Simple APIs for beginners, robust implementations for professional work.
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>
);
}
MIT License — open for both personal and commercial use.
Contributions, issues, and suggestions are welcome.