# idle-detect

> A TypeScript library for inactivity timer, which utilises `IdleDetector` API where possible or a fallback to `window.setTimeout` approach

Latest version **0.2.0** (published 2022-11-14) · MIT license · 0 weekly downloads

## Install

```sh
npm install idle-detect
pnpm add idle-detect
yarn add idle-detect
bun add idle-detect
```

## Health

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

Positive: has types; no vulnerabilities; high quality score.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.2.0 |
| Published | 2022-11-14 |
| First published | 2022-01-07 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 25.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 3 |
| Author | dmythro |
| Maintainers | z-ax, dmythro |
| Keywords | IdleDetector, TypeScript, idle, inactivity, timer, typescript |

## Links

- npm: https://www.npmjs.com/package/idle-detect
- Repository: https://github.com/annexare/IdleDetect
- Homepage: https://github.com/annexare/IdleDetect#readme
- Issues: https://github.com/annexare/IdleDetect/issues
- npm.io page: https://npm.io/package/idle-detect

## Alternatives

- [@openai/codex-sdk](https://npm.io/package/@openai/codex-sdk.md) — 731.4K weekly downloads
- [babel-plugin-transform-react-jsx](https://npm.io/package/babel-plugin-transform-react-jsx.md) — 565.0K weekly downloads
- [babel-helper-remove-or-void](https://npm.io/package/babel-helper-remove-or-void.md) — 508.5K weekly downloads
- [@pnpm/store-controller-types](https://npm.io/package/@pnpm/store-controller-types.md) — 186.9K weekly downloads
- [react-native-signature-canvas](https://npm.io/package/react-native-signature-canvas.md) — 155.6K weekly downloads

## Recent versions

- 0.2.0 (latest) — 2022-11-14
- 0.1.2 — 2022-08-17
- 0.1.1 — 2022-01-10
- 0.1.0 — 2022-01-07

## README

# Idle Detect

A TypeScript library for inactivity timer, which utilises [IdleDetector API](https://developer.mozilla.org/en-US/docs/Web/API/IdleDetector) where possible or a fallback to `window.setTimeout` approach.

## Usage

```bash
npm install idle-detect
```

```ts
import IdleDetect from 'idle-detect'
// Or, if you don't want to use still experimental IdleDetector API:
// import { IdleDetect } from 'idle-detect/dist/IdleDetect'

const onInactive = () => {
  console.info('User is inactive now')
}
const idleDetect = new IdleDetect(15 * 60, onInactive)

// Start timer, e.g. when user is logged in
idleDetect.start()

// End timer, e.g. when user is logged out
idleDetect.cleanupAndStop()
```

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