use-idle-detection
Version:
Custom hook to detect user's idle state
50 lines (33 loc) • 889 B
Markdown
Custom hook to detect if the user is idle or not.
```bash
npm install use-idle-detection
```
with yarn:
```bash
yarn add use-idle-detection
```
```jsx
import React from "react"
import useIdleDetection from "use-idle-detection"
const App = () => {
const { isIdle } = useIdleDetection({
timeout: 1000
})
return (
<div>
<h1>{isIdle ? "Idle" : "Not Idle"}</h1>
</div>
)
}
```
| Name | Type | Default | Description |
| ----------- | -------- | ------- | --------------------------------------------------------------------- |
| idleTimeout | `number` | `3000` | The amount of time in milliseconds before the user is considered idle |
MIT
---
Made with ❤️ by [Muzammil Bilwani](https://muzammilbilwani.com)