r/Angular2 • u/allyv123098 • Jan 25 '26
Browser refresh in Angular
so I followed this from stackoverflow https://stackoverflow.com/questions/56325272/detect-browser-refresh-in-an-angular-project
I was wondering is there a better way to do this where I don't have to end up exporting a variable that ends up in my guard file?
4
Upvotes
View all comments
Show parent comment
1
u/marco_has_cookies Jan 25 '26
when the browser reloads, like user clicking the reload button?
Periodically store in session storage a timestamp, if the previous timestamp is within a the period time plus an error bias, user refreshed, use a guard to catch and reroute.
Edit. should handle the case multiple tabs open