Launch Week Day 1: Socket for Jira Is Now Available.Learn More
Socket
Book a DemoSign in
Socket

@capacitor/network

Package Overview
Dependencies
Maintainers
18
Versions
1059
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@capacitor/network

The Network API provides network and connectivity information.

latest
Source
npmnpm
Version
8.0.1
Version published
Maintainers
18
Created
Source

@capacitor/network

The Network API provides network and connectivity information.

Install

npm install @capacitor/network
npx cap sync

Example

import { Network } from '@capacitor/network';

Network.addListener('networkStatusChange', status => {
  console.log('Network status changed', status);
});

const logCurrentNetworkStatus = async () => {
  const status = await Network.getStatus();

  console.log('Network status:', status);
};

API

  • getStatus()
  • addListener('networkStatusChange', ...)
  • removeAllListeners()
  • Interfaces
  • Type Aliases

getStatus()

getStatus() => Promise<ConnectionStatus>

Query the current status of the network connection.

Returns: Promise<ConnectionStatus>

Since: 1.0.0

addListener('networkStatusChange', ...)

addListener(eventName: 'networkStatusChange', listenerFunc: ConnectionStatusChangeListener) => Promise<PluginListenerHandle>

Listen for changes in the network connection.

ParamType
eventName'networkStatusChange'
listenerFuncConnectionStatusChangeListener

Returns: Promise<PluginListenerHandle>

Since: 1.0.0

removeAllListeners()

removeAllListeners() => Promise<void>

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

Since: 1.0.0

Interfaces

ConnectionStatus

Represents the state and type of the network connection.

PropTypeDescriptionSince
connectedbooleanWhether there is an active connection or not.1.0.0
connectionTypeConnectionTypeThe type of network connection currently in use. If there is no active network connection, connectionType will be 'none'.1.0.0

PluginListenerHandle

PropType
remove() => Promise<void>

Type Aliases

ConnectionType

The type of network connection that a device might have.

'wifi' | 'cellular' | 'none' | 'unknown'

ConnectionStatusChangeListener

Callback to receive the status change notifications.

(status: ConnectionStatus): void

Keywords

capacitor

FAQs

Package last updated on 12 Feb 2026

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts