DEV Community

Discussion on: πŸš€ Detecting If a User is Online/Offline with JavaScript

Collapse
 
dvg3012 profile image
dvg3012

Nice explanation!
Nevertheless, I recently had to implement such a feature and found the navigator online/offline not really reliable. Especially if you've to support different devices, browsers, OS and Frameworks(Electron, Cordova,...).
I went with a workaround consisting of the navigator API and a fetch request to an external endpoint to really make sure a connection exists.
Hope this helps, if someone struggles with the raw navigator API.

Collapse
 
nialljoemaher profile image
Niall Maher

Totally agree, this isn't a silver bullet! This is just one of the ways to handle things. I use this combined with service workers and error handling.