DEV Community

Filip
Filip

Posted on • Edited on

react-activity-detector - Check if the user is idle

I haven't been active in the OS community, or here, but that might change!
Most of my career I was focused on the backend (C# and partially Java), but I felt that I need push myself to something new.
New projects came, and required me to push myself from my comfort zone, and required me to learn ReactJS, and before that JavaScript.
I must say, it's a lot of fun working with ReactJS (in good and bad way).
It's pretty easy to pickup (mostly saying this since I have spend a lot of time working with strong typing languages like C# and Java).

Now, to the package!

You can check the package on react-activity-detector

What's its purpose?
If you have an app, and need to detect if the user is idle after N seconds/minutes/hours + cross tab functionality!

How to implement it

import ActivityDetector from 'react-activity-detector';

const customActivityEvents = [
    'click',
    'keydown',
];

const signOut = () => {
console.log("The user is loged out");
}

<ActivityDetector activityEvents={customActivityEvents} isActive={true} timeout={5*1000} signOut={signOut}/>

Enter fullscreen mode Exit fullscreen mode

You can find more on the link, and to check out the code you can visit github.com.

Just a note, it's still in early stage and I would be grateful for any suggestions or feedbacks!

Postmark Image

20% off for developers shipping features, not fixing email

Build your product without worrying about email infrastructure. Our reliable delivery, detailed analytics, and developer-friendly API let you focus on shipping features that matter.

Start free

Top comments (0)

Image of Datadog

Keep your GPUs in check

This cheatsheet shows how to use Datadog’s NVIDIA DCGM and Triton integrations to track GPU health, resource usage, and model performance—helping you optimize AI workloads and avoid hardware bottlenecks.

Get the Cheatsheet

👋 Kindness is contagious

Engage with a wealth of insights in this thoughtful article, valued within the supportive DEV Community. Coders of every background are welcome to join in and add to our collective wisdom.

A sincere "thank you" often brightens someone’s day. Share your gratitude in the comments below!

On DEV, the act of sharing knowledge eases our journey and fortifies our community ties. Found value in this? A quick thank you to the author can make a significant impact.

Okay