Browser troubleshooting

Do not treat navigator.onLine as an API health check

Navigator.onLine is a connectivity hint, not proof that your particular API is reachable. Attempt the real request and handle its outcome even when the browser reports online.

Worked example

Browser console example · use a disposable page on your own site

console.log("Browser connectivity hint:", navigator.onLine);
// In the app's actual request handler:
// try { const response = await fetch('/api/status'); ... }
// catch { show a retry action and keep the user's input }

How it works

A device may be connected to a network while a captive portal, DNS issue, server outage, or policy blocks the destination. Conversely, platform heuristics can produce an offline hint in situations where some local resources remain available.

Limits and mistakes

Do not disable all useful interface controls solely because this flag is false. An online event does not prove a previously failed write succeeded or should be replayed blindly. Retrying state-changing requests requires an idempotency strategy.

Check the result

Compare the flag with a controlled request to the intended endpoint. Test offline and server-error cases separately, and verify the UI preserves unsent work with a clear retry path.

Sources

Reference documentation for the behavior used in this guide: