Web Features
Idle Detection API

Idle Detection API

The Idle Detection API is a web API that allows a website or web application to detect when a user is idle, i.e. not actively interacting with their device.

Idle Detection API Logo

Demo

Click on the button below and stop touching your device for 30 seconds.

How it works

The Idle Detection API goes beyond just detecting whether a tab is or visible and in focus , it considers both user activity (like mouse movements, keyboard input, or touch events) and device activity (like whether the screen is locked or the device is asleep). The API can return four different statuses:

  1. userState: active → the user is actively using their device
  2. userState: idle → the user is not actively using their device
  3. screenState: locked → the screen is locked
  4. screenState: unlocked → the screen is unlocked

Use cases

  • Logging out users after inactivity for security reasons.
  • Pausing sensitive operations or notifications when the user is away.
  • Power-saving or optimizing resource usage in web apps when the user is idle.
  • Tracking engagement in collaborative apps.

API

window.IdleDetector

Code

Links & Documentation

Your app here

Ready to generate your PWA?

Try our PWA toolkit free of charge and without limits for 14 days. No credit card required.

Generate PWA See plans