use-idle

hook for detecting when a user is idle

Usage no npm install needed!

<script type="module">
  import useIdle from 'https://cdn.skypack.dev/use-idle';
</script>

README

use-idle

hook for detecting when a user is idle (wrapper around activity-detector)

NPM JavaScript Style Guide

Install

npm install --save use-idle

Usage

import React from "react";
import { useIdle } from "use-idle";

const Example = () => {
  const isIdle = useIdle();
  useEffect(() => {
    isIdle && alert("You've gone idle!");
  }, [isIdle]);

  return <div>Don't move a damn muscle.</div>;
};

License

MIT © @mayteio


This hook is created using create-react-hook.