Skip to content

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

License

Notifications You must be signed in to change notification settings

annexare/IdleDetect

Repository files navigation

Idle Detect

IdleDetect Tests Monthly Downloads

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

Usage

npm install idle-detect
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()

About

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

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published