CautionA true value only indicates that the device is connected to a network; it does not guarantee actual internet access or server reachability.
The useOnline hook utilizes useSyncExternalStore to subscribe to the browser's online and offline window events. It provides a real-time reactive boolean based on the navigator.onLine API, ensuring that the component stays in sync with the network state and providing a safe default for Server-Side Rendering (SSR) to avoid hydration mismatches.
| Name | Type | Description |
|---|---|---|
| online | boolean | Returns true if the browser is online, and false otherwise. Note that true doesn't necessarily guarantee internet access, only a connection to a network. |