idle-vue is a Vue.js plugin designed to detect user inactivity within a Vue 2 application. It leverages the underlying `idle-js` library to provide a reactive and integrated solution for monitoring when a user has not interacted with the application for a specified duration. The package is currently at version 2.0.5 and, as a Vue 2-specific plugin, its release cadence is likely stable, focused on maintenance rather than frequent new features, aligning with the lifecycle of Vue 2 itself. It offers three primary mechanisms for handling idle states: `onIdle` and `onActive` lifecycle hooks accessible in any Vue component, a computed property `isAppIdle` for reactive state management, and an optional `IdleView` component for a default idle overlay. A key differentiator is its flexible integration, allowing users to either provide an `eventEmitter` (a Vue instance) for hook-based responses or a Vuex `store` for state-driven reactivity, providing developers with robust options for building responsive user experiences around inactivity detection without boilerplate DOM event handling.
npm install idle-vueVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to set up `idle-vue` using an `eventEmitter` to detect user inactivity and respond via `onIdle` and `onActive` hooks, updating the UI accordingly.
For Vue 3 projects, consider alternative libraries or implement idle detection manually using standard browser APIs.
Ensure that the options object passed to `Vue.use(IdleVue, options)` includes either `eventEmitter: new Vue()` or `store: new Vuex.Store({...})`.To use the hooks, pass `eventEmitter: new Vue()` in the plugin options. If using a Vuex store, ensure the store is correctly configured and passed.
To utilize `isAppIdle` or the `IdleView` component, pass `store: new Vuex.Store({...})` in the plugin options and ensure the store is correctly imported and provided to your root Vue instance.Ensure `import IdleVue from 'idle-vue'` is present and `Vue.use(IdleVue, ...)` is called with the imported plugin.
Pass a Vuex store instance in the plugin options: `Vue.use(IdleVue, { store })` and ensure the store is provided to your root Vue instance.Provide an `eventEmitter` in the plugin options: `const eventsHub = new Vue(); Vue.use(IdleVue, { eventEmitter: eventsHub, ... })`.