Skip to content
aq-ui
Back to HooksHook

Use Idle

Open-code aq-ui React hook for Use Idle.

Installation

pnpm dlx aq-ui@alpha add use-idle

API reference

Client module

Import the parts you need, then jump to an export for its contract.

View full source

Quick start

"use client"

import { useIdle } from "@/hooks/use-idle"

const result = useIdle()

useIdle

functionSource L24

Open-code aq-ui React hook for Use Idle.

function useIdle({ timeout = 60_000, initialState = false, enabled = true, events = DEFAULT_IDLE_EVENTS, onIdle, onActive, }: UseIdleOptions = {}): boolean
Returns
boolean

Parameters

NameTypeDefault
options?UseIdleOptions{}
const result = useIdle()

UseIdleOptions

interfaceSource L7

Type contract for UseIdleOptions.

interface UseIdleOptions

Members

NameTypeDefault
timeout?number60_000
initialState?booleanfalse
enabled?booleantrue
events?Array<keyof WindowEventMap>DEFAULT_IDLE_EVENTS
onIdle?() => void—
onActive?() => void—

Registry dependencies

use-stable-callback

Files

  • hooks/use-idle.ts

Source