navigator.onLine
A browser property that is true when the browser believes it has a network connection, paired with online and offline events on window.
In more detail
A true value only means some network is available, not that your server is reachable. The events fire when the connection state changes.
Example
The course reads it with useSyncExternalStore: subscribe to the two events, read navigator.onLine as the snapshot and assume online on the server.Related terms
- useSyncExternalStore — The React hook for reading data from a store outside React, such as a state library or a browser API, without tearing.
- event listener — A function registered with addEventListener that the browser calls whenever a given event happens on an element or on window.
Taught in
- useSyncExternalStore: Tearing-Free Store Subscriptions — React 19 & Modern Component Architecture