Network API
Current connectivity and a stream of changes.
Native enablement is internalPlugins.network. The dependency is @capacitor/network@8.0.1. Notifications also enable this capability through the internal registry.
getNetworkStatus is an Effect of NetworkStatus. watchNetworkStatus is a Stream of NetworkStatus. Both require Bridge | BrowserNetwork and fail with BridgeError.
| Field | Values |
|---|---|
connected | Boolean describing local connectivity. Does not prove endpoint reachability. |
connectionType | wifi, cellular, none, unknown, ethernet, bluetooth, wimax, or other |
| Runtime | Connection types |
|---|---|
| Android and iOS | wifi, cellular, none, unknown; offline uses none |
| Browser | Browser-dependent; online without type information uses unknown |
NetworkStatusSchema and NetworkTypeSchema validate results. The stream subscribes before its initial read, suppresses duplicate statuses, and retains the latest pending status. Scope closure removes the listener.
networkLive(effect) provides BrowserNetworkLive. browserNetworkLayer(read) builds a layer from a browser network source. BrowserNetwork separates current status and event subscription for tests.
useNetworkStatus() returns loading state, value, and error. It starts after mount and updates live. Native listener absence produces BridgeUnavailable. Malformed native results or events produce BridgeDecodeError.
Platform support
| Capability | Android | iOS | Browser |
|---|---|---|---|
| Status and changes | Native Network plugin | Native Network plugin | Browser network source |
| Endpoint reachability | Not established | Not established | Not established |
Source: network implementation.