Many browsers have implemented events “online” and “offline”; in addition to this, browsers also expose the navigator.onLine
property that will return “online” or “offline”
How many browsers is many?
caniuse says every major browser (Chrome, Firefox, Safair, IE11…) except Opera mini has this functionality (as of July 4th 2018).
How can I check the online status?
> navigator.onLine
How can I listen to events?
BE LOUD
Be loud if core functionality depends on staying online
If your app depends on autosaving,
BE LOUD ABOUT NOT BEING ABLE TO SAVE.
Be like workflowy*. Tell the users, make them listen.
Caveats
You will likely need more error handling than this. For example: what if your server is offline? what if the request body has malformed? what if the server is up but your database is down? what if the api hits a 404 and do you let your devs know about this?
* referral link