This is something useful for apps which after a period of inactivity time you need to autosave things, clear localStorage, redirect to a logout URL and many other background things, so it does not matter if you are using VueJS or ReactJS you can add this code <!-- Script --> < script type= 'text/javascript' > var inactivityTime = function () { var time; window .onload = resetTimer; // DOM Events document .onload = resetTimer; document .onmousemove = resetTimer; document .onmousedown = resetTimer; // touchscreen presses document .ontouchstart = resetTimer; document .onclick = resetTimer; // touchpad clicks document .onscroll = resetTimer; // scrolling with arrow keys document .onkeypress = resetTimer; window .addEventListener( 'scroll' , resetTimer, true ); let count = 0 ; function logout () { //localStorage.clear(); //alert("You are now logged out.") /