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.
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.
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.