See how Capacitor fits into the entire Ionic Ecosystem ->
Capacitor is part of the Ionic Ecosystem ->

@capacitor/network

The Network API provides network and connectivity information.

Install

npm install @capacitor/network
npx cap sync

API

getStatus()

getStatus() => Promise<NetworkStatus>

Query the current status of the network connection.

Returns: Promise<NetworkStatus>

Since: 1.0.0


addListener(…)

addListener(eventName: 'networkStatusChange', listenerFunc: (status: NetworkStatus) => void) => PluginListenerHandle

Listen for changes in the network connection.

Param Type
eventName "networkStatusChange"
listenerFunc (status: NetworkStatus) => void

Returns: PluginListenerHandle

Since: 1.0.0


removeAllListeners()

removeAllListeners() => void

Remove all listeners (including the network status changes) for this plugin.

Since: 1.0.0


Interfaces

NetworkStatus

Represents the state and type of the network connection.

Prop Type Description Since
connected boolean Whether there is an active connection or not. 1.0.0
connectionType "wifi" | "cellular" | "none" | "unknown" The type of network connection currently in use. If there is no active network connection, connectionType will be 'none'. 1.0.0

PluginListenerHandle

Prop Type
remove () => void
Previous
<- Motion
Next
Screen Reader ->