npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

idle-manager-js

v1.2.4

Published

Detect user inactivity and track active state with ease.

Readme

Idle Manager Js

Idle Manager Js is a library for tracking user activity. It allows you to detect when a user becomes inactive and react to user activity, which can be useful for applications that require auto-session termination or timeout actions.

Installation

To install the library, execute one of the commands:

npm install idle-manager-js
yarn add idle-manager-js
pnpm add idle-manager-js

Usage

Basic Example

import IdleManager from 'idle-manager-js';

const idleManager = new IdleManager({
  idleTime: 300000, // Time of inactivity in milliseconds (e.g., 5 minutes)
  onIdle: () => {
    console.log('User is idle');
    // Perform actions when the user is idle (e.g., log out or end session)
  },
  onActive: () => {
    console.log('User is active');
    // Perform actions when the user becomes active again (e.g., restore session)
  },
});

idleManager.start(); // Starts tracking user activity

Configuration

  • idleTime (optional):
    The time of inactivity in milliseconds after which the user is considered idle.
    Default: 60000 milliseconds (1 minute)

  • onIdle (required):
    A callback function that will be triggered when the user becomes idle.

  • onActive (required):
    A callback function that will be triggered when the user becomes active again.

  • events (optional):
    An array of event types to listen for user activity. Default: ['mousemove', 'keydown', 'mousedown', 'touchstart', 'touchmove', 'visibilitychange', 'scroll', 'resize']

    • mousemove Any movement of the mouse indicates user activity.
    • keydown Pressing keys on the keyboard, for example, when the user is typing text.
    • mousedown Pressing the mouse button, which often occurs when interacting with elements.
    • touchstart The start of a touch event on mobile devices.
    • touchmove Movement of a finger on a mobile device's screen.
    • visibilitychange The visibility change of the page (e.g., switching tabs).
    • scroll Scrolling the page or an element, which is a clear sign of user activity.
    • resize Changing the browser window size (sometimes used to track activity).

Methods

start()

Starts tracking user activity. Begins listening for activity events and resets the timer on each event.

stop()

Stops tracking user activity. Removes all event listeners and clears the timer.

resetTimer()

Automatically resets the timer whenever an activity event (e.g., mouse movement or key press) occurs. If the page loses focus, the user is considered idle.

triggerIdle()

Triggers the idle timeout, marking the user as idle.

License

This project is licensed under the MIT License.

Support the Project 💖

If you find idle-manager-js useful and want to support its development, consider making a donation:

Donate via PayPal

Contributing

We welcome contributions! If you have ideas, improvements, or fixes — please feel free to create a Pull Request or open an Issue.

npm