# @barelyreaper/background-timer

> Simple react hook to run a timer in the background

Latest version **0.0.13** (published 2020-12-05) · MIT license · 0 weekly downloads

## Install

```sh
npm install @barelyreaper/background-timer
pnpm add @barelyreaper/background-timer
yarn add @barelyreaper/background-timer
bun add @barelyreaper/background-timer
```

## Health

**Score 20/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities.

Warnings: low downloads; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.13 |
| Published | 2020-12-05 |
| First published | 2020-12-01 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 5.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 4 |
| Author | Reaper |
| Maintainers | barelyreaper |
| Keywords | background-timer, timer, otp, react-native, react |

## Links

- npm: https://www.npmjs.com/package/@barelyreaper/background-timer
- Repository: https://github.com/barelyhuman/background-timer
- Issues: https://github.com/barelyhuman/background-timer/issues
- npm.io page: https://npm.io/package/@barelyreaper/background-timer

## 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

- 0.0.13 (latest) — 2020-12-05
- 0.0.13-dev.0 (beta) — 2020-12-29
- 0.0.12 — 2020-12-04
- 0.0.11 — 2020-12-04
- 0.0.10 — 2020-12-04
- 0.0.9 — 2020-12-04
- 0.0.7 — 2020-12-04
- 0.0.6 — 2020-12-04
- 0.0.5 — 2020-12-04
- 0.0.4 — 2020-12-03
- 0.0.3 — 2020-12-03
- 0.0.2 — 2020-12-01
- 0.0.1 — 2020-12-01

## README

# background-timer

Simple react hook to run a timer in the background

## Motivation
Nothing really, pulled it off a project I wrote it for and now it's a package.

## Install

```sh
npm i @barelyreaper/background-timer
```

## Usage

```js
import { useBackgroundTimer, msTimestamp } from 'background-timer';

export default function App() {
  /**
   * @param milliseconds
   * @returns {timer: milliseconds, reset: function} resets the timer
   */

  const { timer, reset } = useBackgroundTimer(2 * 1000 * 60,{
    onTimerEnd:()=>{
      alert("Timer Ended");
    }
  });
  

  return <>
    <p>{msTimestamp(timer)}</p>
    <button disabled={timer>0} onClick={()=>reset()}>Reset Timer</button>
  </>;
}
```

---
_Source: https://npm.io/package/@barelyreaper/background-timer · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
