You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

react-idle-timer-hook-ui

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-idle-timer-hook-ui

A reusable React idle timer component with auto-logout

1.0.9
latest
npmnpm
Version published
Weekly downloads
43
-93.78%
Maintainers
1
Weekly downloads
 
Created
Source

💤 react-idle-timer-hook-ui

A lightweight and customizable React component that tracks user inactivity and executes a logout (or custom action) after a specified idle period. Perfect for building secure session-based apps.

npm license

🚀 Features

  • Detects user inactivity from common events like mouse, keyboard, or touch
  • Automatically triggers a logout or custom handler
  • Customizable idle duration
  • Plug-and-play: easily drop into any React app

📦 Installation

npm install react-idle-timer-hook-ui

📄 Usage

import React from 'react';
import IdleTimer from 'react-idle-timer-hook-ui';

function App() {
  const handleLogout = () => {
    alert('You have been logged out due to inactivity.');
    // Your logout logic here (e.g. redirect or token clear)
  };

  return (
    <div>    
      <IdleTimer idleTime={5} logout={handleLogout} />
      <h1>Welcome to My App</h1>
    </div>
  );
}

export default App;

🔍 Explanation

idleTime={5}

The time (in seconds) that the user must be inactive before being considered "idle".
In this example, 5 means the user will be logged out after 5 seconds of no mouse, keyboard, or touch interaction.

logout={handleLogout}

A callback function that gets triggered when the user becomes idle for the defined duration.
You can perform any logic here, such as:

  • Logging the user out
  • Clearing authentication tokens
  • Redirecting to the login screen

Keywords

react

FAQs

Package last updated on 30 Jul 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.