TipYou can customize the events array to exclude specific interactions—for example, removing scroll to ignore page movement as an "active" state.
NoteThis hook is a state reporter only; it does not perform automated actions like session timeouts or logouts.
The useIdle observes a customizable set of browser events (such as mousemove, keydown, or scroll). Each detected interaction resets an internal timer; if no activity occurs before the timeout expires, the user is marked as idle. This hook is purely reactive, allowing developers to trigger side effects like session timeouts, pausing expensive computations, or UI state changes.
| Name | Type | Description |
|---|---|---|
| isIdle | boolean | Returns true if the timeout has been reached without user interaction. |
| lastActiveAt | number | The timestamp (ms) of the most recent user activity detected. |