# react-interval-hook

> React hook for using self-correcting setInterval, augmented by management methods (start, stop, isActive)

Latest version **1.1.5** (published 2025-03-16) · MIT license · 0 weekly downloads

## Install

```sh
npm install react-interval-hook
pnpm add react-interval-hook
yarn add react-interval-hook
bun add react-interval-hook
```

## Health

**Score 50/100 (C)** — status: stable.

Positive: has types; esm support; no vulnerabilities; has provenance.

Warnings: low downloads.

Negative: stale.

## Facts

| | |
|---|---|
| Version | 1.1.5 |
| Published | 2025-03-16 |
| First published | 2020-05-03 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 6.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Provenance | attested (GitHub Actions) |
| GitHub stars | 67 |
| Author | minwork |
| Maintainers | minwork |
| Keywords | interval, hook, react, setInterval, self-correcting |

## Links

- npm: https://www.npmjs.com/package/react-interval-hook
- Repository: https://github.com/minwork/react
- Homepage: https://minwork.gitbook.io/react-interval-hook/
- Issues: https://github.com/minwork/react/issues
- npm.io page: https://npm.io/package/react-interval-hook

## Alternatives

- [mobx-react](https://npm.io/package/mobx-react.md) — 2.8M weekly downloads
- [rc-tree](https://npm.io/package/rc-tree.md) — 2.6M weekly downloads
- [@react-oauth/google](https://npm.io/package/@react-oauth/google.md) — 1.3M weekly downloads
- [@wagmi/connectors](https://npm.io/package/@wagmi/connectors.md) — 877.0K weekly downloads
- [vee-validate](https://npm.io/package/vee-validate.md) — 836.4K weekly downloads

## Recent versions

- 1.1.5 (latest) — 2025-03-16
- 1.1.5-preview.1 (preview) — 2025-03-01
- 1.1.5-preview.0 — 2024-09-06
- 1.1.4 — 2023-08-30
- 1.1.4-alpha.2 — 2023-08-30
- 1.1.4-alpha.1 — 2023-08-29
- 1.1.3 — 2021-04-24
- 1.1.2 — 2020-09-12
- 1.0.3 — 2020-06-13
- 1.0.2 — 2020-05-09
- 1.0.1 — 2020-05-04
- 1.0.0 — 2020-05-03

## README

# React Interval Hook

[![codecov](https://codecov.io/gh/minwork/react/branch/main/graph/badge.svg?token=2KPMMSLDOM)](https://codecov.io/gh/minwork/react)
![npm type definitions](https://img.shields.io/npm/types/react-interval-hook)
![NPM Downloads](https://img.shields.io/npm/dm/react-interval-hook)
[![npm](https://img.shields.io/npm/v/react-interval-hook)](https://www.npmjs.com/package/react-interval-hook)
![npm bundle size](https://img.shields.io/bundlephobia/minzip/react-interval-hook)

![React Interval Hook](https://raw.githubusercontent.com/minwork/react/main/packages/react-interval-hook/images/react-interval-hook.webp)

> React _self-correcting_ interval hook for precision timing, augmented by management methods

## Main features

-   Self-correcting ([explanation](https://stackoverflow.com/a/29972322/10322539))
-   Manageable (start, stop, isActive)
-   Thoroughly tested

## Installation

```bash
yarn add react-interval-hook
```

or

```bash
npm install --save react-interval-hook
```

# Basic usage

```tsx
import React from 'react'; // No longer necessary in newer React versions
import { useInterval } from 'react-interval-hook';

export const Example = () => {
    useInterval(() => {
        console.log('I am called every second');
    });
    
    return null;
};
```

# Documentation

Full documentation can be found [here](https://minwork.gitbook.io/react-interval-hook/)

# Support

If you like my work, consider making a [donation](https://github.com/sponsors/minwork) through Github Sponsors.

# License

MIT © [minwork](https://github.com/minwork)

---
_Source: https://npm.io/package/react-interval-hook · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
