Skip to Content
Platform.Ontology

Online and offline state

Tells the page whether the device believes it has a network.

Gets silentlyNetwork and connectionConnection stateWeb browsersWhen the page loadsWhile you use it

In one line

Can tell if your device thinks it is online, and when that changes

Tells the page whether the device believes it has a network.

Boolean only; true can still mean a captive portal or no internet. Events fire when the device loses or regains connection, revealing travel, elevators, flights.

What it can and can't do

What the user does: Nothing. It happens while the page is open and your connection changes

It can

  • See a yes or no answer for being online
  • Notice when you lose or regain a connection
  • Switch to an offline mode and save your work for later

It cannot

  • Know if the internet truly works, since a hotel login page still counts as online
  • See which network you are on
  • See your location, though repeated drops can hint you are on the move
  • Work after you close the tab

Browser support

BrowserStatusFirst versionReleasedNote
ChromeSupported22009-05-21None
EdgeSupported122015-07-29None
FirefoxSupported1.52005-11-29None
SafariSupported42009-06-08None
Safari on iPhoneSupported3.22010-04-03None
Chrome on AndroidSupported182012-06-27None
Samsung InternetSupported1.02013-04-27None

How a site asks for it

APInavigator.onLine, 'online' and 'offline' events
Browser compat keysapi.Navigator.onLine
How access is grantednone
What the user seesNone
Needs a secure context (HTTPS)No
Needs a user gestureNo
How long it lastsread fresh on every page load; nothing stored
How to take it backnone needed (no grant)
Inside an iframeReadable from cross-origin iframes too (same values)

Typical flow

  1. Page script reads the value
  2. No prompt is shown

Data you get

Shape: object
How often: static per session

FieldTypeUnitRangePrecision
onLinebooleanNonetrue or falseNot listed

Technical limits

  • True means a link, not working internet

The story

What it is

A page knows whether your device thinks it is online, and gets told when that changes.

For you

You may see a banner like You are offline, or a message that your changes will sync later. When the signal returns, the page catches up for you.

For makers

Makers use it to protect user work, to switch to a saved copy and to retry actions. It is a simple signal, but it can be wrong, as a device can look online with no real internet.

Where you see it

TypeExampleApps
productivityGoogle Docs shows Offline in the top bar when your signal drops, keeps your typing and syncs when you reconnect.Google Docs
gamesA browser game pauses and shows Reconnecting when the signal drops, then rejoins the match when it returns.None named
videoA web streaming app switches to downloaded titles when it sees the device is offline.Netflix
socialA chat site shows a clock icon on unsent messages while offline and sends them when back online.None named
shoppingA shop keeps a cart on the device when offline and syncs it when online.None named
creativeA web design tool like Figma warns that edits are saved on this device only until a connection returns.Figma
newsA news site shows saved articles while you ride through a tunnel.None named

Risks

  • Can be wrong
  • Little privacy risk

What the platform says

Good uses and abuse

Legitimate uses

  • Offline mode

Known abuse

  • Presence timing

Scores

ScoreValueMeaning
Sensitivity1 of 5How revealing the data is
Utility4 of 5How useful it is to honest apps
Friction0 of 5How much the user has to do
Fingerprint bits0.1Rough identifying entropy, when known

Sources

How well checked: Based on official documentation.

On this page