1
setInterval(function(){
    if(!isOnline && navigator.onLine){
        isOnline = true;
        console.log("Back online!");
    }
    else if(isOnline && !navigator.onLine){
        isOnline = false;
        console.log("Lost connection!");
}}, 100);

Is it possible to subscribe to data from 'navigator.online'?

The above method seems to be working fine in developer options, when comes to real-time it only checks whether my device is connected to a network or not.

What I want is how to check the status of the internet connectivity.

fatihyildizhan
  • 8,614
  • 7
  • 64
  • 88
Vino
  • 57
  • 5
  • not an ideal solution - but it's safe to ask dns. If dns answers, you are connected https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/dns/resolve – WiatroBosy Dec 28 '22 at 17:54
  • 2
    or have look at this one: [link](https://stackoverflow.com/questions/42927071/check-web-app-is-online-or-offline) – Basement Pilot Dec 28 '22 at 20:08

0 Answers0