
Product
Announcing Socket Fix 2.0
Socket Fix 2.0 brings targeted CVE remediation, smarter upgrade planning, and broader ecosystem support to help developers get to zero alerts.
@capacitor/network
Advanced tools
The Network API provides network and connectivity information.
npm install @capacitor/network
npx cap sync
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);
};
getStatus() => Promise<ConnectionStatus>
Query the current status of the network connection.
Returns: Promise<ConnectionStatus>
Since: 1.0.0
addListener(eventName: 'networkStatusChange', listenerFunc: ConnectionStatusChangeListener) => Promise<PluginListenerHandle>
Listen for changes in the network connection.
Param | Type |
---|---|
eventName | 'networkStatusChange' |
listenerFunc | ConnectionStatusChangeListener |
Returns: Promise<PluginListenerHandle>
Since: 1.0.0
removeAllListeners() => Promise<void>
Remove all listeners (including the network status changes) for this plugin.
Since: 1.0.0
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 | ConnectionType | The type of network connection currently in use. If there is no active network connection, connectionType will be 'none' . | 1.0.0 |
Prop | Type |
---|---|
remove | () => Promise<void> |
The type of network connection that a device might have.
'wifi' | 'cellular' | 'none' | 'unknown'
Callback to receive the status change notifications.
(status: ConnectionStatus): void
FAQs
The Network API provides network and connectivity information.
The npm package @capacitor/network receives a total of 106,295 weekly downloads. As such, @capacitor/network popularity was classified as popular.
We found that @capacitor/network demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 15 open source maintainers collaborating on the project.
Did you know?
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.
Product
Socket Fix 2.0 brings targeted CVE remediation, smarter upgrade planning, and broader ecosystem support to help developers get to zero alerts.
Security News
Socket CEO Feross Aboukhadijeh joins Risky Business Weekly to unpack recent npm phishing attacks, their limited impact, and the risks if attackers get smarter.
Product
Socket’s new Tier 1 Reachability filters out up to 80% of irrelevant CVEs, so security teams can focus on the vulnerabilities that matter.