Skip to content

useIdle ​

Category
Sensors

Hook that defines the logic when the user is idle

typescript
import { useIdle } from '@siberiacancode/reactuse';

Usage ​

typescript
const { idle, lastActive } = useIdle();

Demo ​

Api ​

Parameters

NameTypeDefaultNote
milliseconds?numberONE_MINUTEThe idle time in milliseconds
options.initialState?booleanfalseThe options for the hook
options.events?Array<keyof WindowEventMap>IDLE_EVENTS

Contributors ​

Source • Demo