useIdle()
The
useIdle() hook tracks user activity (mouse movement, keyboard input, scrolling, etc.) and determines if the user has been inactive for a specified duration.Import
typescript
Usage
User Status
Active
Stop moving your mouse or typing for 3 seconds to trigger the idle state.
(Events monitored: mousemove, keydown, scroll, touch, etc.)
Component.tsx
API
Arguments
ms– number (Optional) The timeout in milliseconds before the user is considered idle. Defaults to 60000 (1 minute).
Returns
Returns a boolean value:
isIdle– boolean True if the user has been inactive for the specified duration, False otherwise.