For demonstraction purpose, the idle timout is set to 5s in this demo (default 1min).
Idle: false
Inactive: 0s

useIdle

Tracks whether the user is being inactive.

Usage

import { useIdle } from '@vueuse/core'

const { idle, lastActive } = useIdle(5 * 60 * 1000) // 5 min

console.log(idle.value) // true or false

Type Declarations

export interface IdleOptions
  extends ConfigurableWindow,
    ConfigurableEventFilter {
  /**
   * Event names that listen to for detected user activity
   *
   * @default ['mousemove', 'mousedown', 'resize', 'keydown', 'touchstart', 'wheel']
   */
  events?: WindowEventName[]
  /**
   * Listen for document visibility change
   *
   * @default true
   */
  listenForVisibilityChange?: boolean
  /**
   * Initial state of the ref idle
   *
   * @default false
   */
  initialState?: boolean
}
/**
 * Tracks whether the user is being inactive.
 *
 * @link /useIdle
 * @param timeout default to 1 minute
 * @param options IdleOptions
 */
export declare function useIdle(
  timeout?: number,
  options?: IdleOptions
): {
  idle: Ref<boolean>
  lastActive: Ref<number>
}

Source

SourceDemoDocs