cordova-plugin-network-information (3.1.0, May 2026) adds navigator.connection.type, with values such as wifi, 4g, 5g and none, and fires offline and online on document. While the snippet below waited, a second terminal turned the emulator's radios off and on again with adb -s emulator-5558 shell svc wifi disable and svc data disable, then enable:
const seen = [];
for (const type of ['offline', 'online']) {
document.addEventListener(type, () => seen.push(`${type}: ${navigator.connection.type}`));
}
const before = navigator.connection.type;
await new Promise((resolve) => setTimeout(resolve, 15000)); // Wi-Fi and data off, then on
({ before, seen, after: navigator.connection.type });{
before: 'wifi',
seen: [ 'online: 5g', 'offline: none', 'online: 5g', 'online: wifi' ],
after: 'wifi'
}The plugin fires online on every change to a working connection, not only after an outage: switching Wi-Fi off moved the app to the emulated mobile network (online: 5g), switching data off too gave offline, and turning them back on produced two more online events. BookNest now shows Offline in its footer on the same event. Treat online as "a network exists", not "the server is reachable".
Background execution is Cordova 129 's weakest spot. cordova-plugin-background-mode was last published in August 2019 (0.7.3), before Android 14 required every foreground service to declare its type, and it has no maintained successor. Schedule deferred work with WorkManager 234 in a custom plugin (Custom Plugins), or do it on a server and wake the app with a push message (Sharing and Firebase).