Founding price: $35, then $99 after 23:59 UTC on 4 November, then $99
Get ProReport true after a period with no pointer, keyboard, scroll or touch activity, and false again as soon as the person returns.
Derived from this item’s props table, because it declares no controls of its own. This item has no standalone playground, so changes update the code, the share link and the AI prompt.
Use it for an "are you still there?" prompt, dimming a kiosk, pausing a poll, marking someone away or hiding controls after a quiet moment in a video player.
Do not use it as the only guard for security timeouts; enforce session expiry on the server.
import { useIdle } from "@/hooks/use-idle"const idle = useIdle(60_000)useIdle(timeout = 60000, options?): boolean
| Option | Type | Default | Description |
|---|---|---|---|
events | string[] | pointermove, pointerdown, keydown, wheel, touchstart, scroll | Window events that count as activity. |
initialState | boolean | false | The value before any timer has run. |
Listeners are passive and are removed on unmount. When the tab becomes visible again the hook treats it as activity. Nothing runs on the server.
A hook has no markup. If idleness triggers a warning or sign-out, use a dialog that takes focus, gives enough time to respond and can be extended with a single key press (WCAG 2.2.1).
The hook ships with renderHook tests (use-idle.test.ts) covering its behaviour, cleanup on unmount and server-safe defaults. It is safe to render on the server.