skip to main content

Check if user is offline

15 October, 2020

Posted in code

It’s pretty easy to check if a user is offline with javascript.

window.addEventListener('offline', () => console.log('is offline'));

This can be useful to display a warning if your application auto-saves at a regular interval.

If the user is offline, the auto-save may fail so a warning message would be a good bit of UX here.