Skip to content

Getting Started

Terminal window
bun add @capgo/capacitor-wifi
bunx cap sync
import { CapacitorWifi } from '@capgo/capacitor-wifi';

Show a system dialog to add a Wi-Fi network to the device. On Android SDK 30+, this opens the system Wi-Fi settings with the network pre-filled. On iOS, this connects to the network directly.

import { CapacitorWifi } from '@capgo/capacitor-wifi';
await CapacitorWifi.addNetwork({
ssid: 'MyNetwork',
password: 'mypassword',
isHiddenSsid: false,
securityType: NetworkSecurityType.WPA2_PSK
});

Connect to a Wi-Fi network. On Android, this creates a temporary connection that doesn’t route traffic through the network by default. Set autoRouteTraffic to true to bind app traffic to the connected network (useful for local/device-hosted APs). For a persistent connection on Android, use addNetwork() instead. On iOS, this creates a persistent connection.

import { CapacitorWifi } from '@capgo/capacitor-wifi';
await CapacitorWifi.connect({
ssid: 'MyNetwork',
password: 'mypassword',
autoRouteTraffic: true // Android only: route app traffic through this network
});

Disconnect from the current Wi-Fi network. On iOS, only disconnects from networks that were added via this plugin.

import { CapacitorWifi } from '@capgo/capacitor-wifi';
await CapacitorWifi.disconnect();

Get a list of available Wi-Fi networks from the last scan. Only available on Android.

import { CapacitorWifi } from '@capgo/capacitor-wifi';
const { networks } = await CapacitorWifi.getAvailableNetworks();
networks.forEach(network => {
console.log(`SSID: ${network.ssid}, Signal: ${network.rssi} dBm`);
});

Get the device’s current IP address. Available on both Android and iOS.

import { CapacitorWifi } from '@capgo/capacitor-wifi';
const { ipAddress } = await CapacitorWifi.getIpAddress();
console.log('IP Address:', ipAddress);

Get the received signal strength indicator (RSSI) of the current network in dBm. Only available on Android.

import { CapacitorWifi } from '@capgo/capacitor-wifi';
const { rssi } = await CapacitorWifi.getRssi();
console.log('Signal strength:', rssi, 'dBm');

Get the service set identifier (SSID) of the current network. Available on both Android and iOS.

import { CapacitorWifi } from '@capgo/capacitor-wifi';
const { ssid } = await CapacitorWifi.getSsid();
console.log('Connected to:', ssid);

Get comprehensive information about the currently connected WiFi network. This method provides detailed network information including SSID, BSSID, IP address, frequency, link speed, and signal strength in a single call. On iOS, some fields may not be available and will be undefined.

import { CapacitorWifi } from '@capgo/capacitor-wifi';
const info = await CapacitorWifi.getWifiInfo();
console.log('Network:', info.ssid);
console.log('BSSID:', info.bssid);
console.log('IP:', info.ip);
console.log('Frequency:', info.frequency, 'MHz');
console.log('Speed:', info.linkSpeed, 'Mbps');
console.log('Signal:', info.signalStrength);

Check if Wi-Fi is enabled on the device. Only available on Android.

import { CapacitorWifi } from '@capgo/capacitor-wifi';
const { enabled } = await CapacitorWifi.isEnabled();
console.log('WiFi is', enabled ? 'enabled' : 'disabled');

Start scanning for Wi-Fi networks. Only available on Android. Results are delivered via the ‘networksScanned’ event listener. Note: May fail due to system throttling or hardware issues.

import { CapacitorWifi } from '@capgo/capacitor-wifi';
await CapacitorWifi.addListener('networksScanned', () => {
console.log('Scan completed');
});
await CapacitorWifi.startScan();

Check the current permission status for location access. Location permission is required for Wi-Fi operations on both platforms.

import { CapacitorWifi } from '@capgo/capacitor-wifi';
const status = await CapacitorWifi.checkPermissions();
console.log('Location permission:', status.location);

Request location permissions from the user. Location permission is required for Wi-Fi operations on both platforms.

import { CapacitorWifi } from '@capgo/capacitor-wifi';
const status = await CapacitorWifi.requestPermissions();
if (status.location === 'granted') {
console.log('Permission granted');
}

Options for adding a network.

export interface AddNetworkOptions {
/**
* The SSID of the network to add
*
* @since 7.0.0
*/
ssid: string;
/**
* The password for the network (optional for open networks)
*
* @since 7.0.0
*/
password?: string;
/**
* Whether the network is hidden (Android only)
*
* @since 7.0.0
* @default false
*/
isHiddenSsid?: boolean;
/**
* The security type of the network (Android only)
*
* @since 7.0.0
* @default NetworkSecurityType.WPA2_PSK
*/
securityType?: NetworkSecurityType;
}

Options for connecting to a network.

export interface ConnectOptions {
/**
* The SSID of the network to connect to
*
* @since 7.0.0
*/
ssid: string;
/**
* The password for the network (optional for open networks)
*
* @since 7.0.0
*/
password?: string;
/**
* Whether the network is hidden (Android only)
*
* @since 7.0.0
* @default false
*/
isHiddenSsid?: boolean;
/**
* Whether to automatically route app traffic through the connected Wi-Fi network (Android only)
* When enabled, it binds the app process to the connected network using ConnectivityManager.bindProcessToNetwork()
* This is useful for connecting to local/device-hosted APs (e.g., ESP32, IoT devices) that don't have internet access.
*
* @since 7.0.0
* @default false
*/
autoRouteTraffic?: boolean;
}

Options for disconnecting from a network.

export interface DisconnectOptions {
/**
* The SSID of the network to disconnect from (optional)
*
* @since 7.0.0
*/
ssid?: string;
}

Result from getAvailableNetworks().

export interface GetAvailableNetworksResult {
/**
* List of available networks
*
* @since 7.0.0
*/
networks: Network[];
}

Result from getIpAddress().

export interface GetIpAddressResult {
/**
* The device's IP address
*
* @since 7.0.0
*/
ipAddress: string;
}

Result from getRssi().

export interface GetRssiResult {
/**
* The signal strength in dBm
*
* @since 7.0.0
*/
rssi: number;
}

Result from getSsid().

export interface GetSsidResult {
/**
* The SSID of the current network
*
* @since 7.0.0
*/
ssid: string;
}

Comprehensive WiFi information.

export interface WifiInfo {
/**
* The SSID (network name) of the current network
*
* @since 7.0.0
*/
ssid: string;
/**
* The BSSID (MAC address) of the access point.
* Not available on iOS.
*
* @since 7.0.0
*/
bssid?: string;
/**
* The device's IP address on the network
*
* @since 7.0.0
*/
ip: string;
/**
* The network frequency in MHz.
* Not available on iOS.
*
* @since 7.0.0
*/
frequency?: number;
/**
* The connection speed in Mbps.
* Not available on iOS.
*
* @since 7.0.0
*/
linkSpeed?: number;
/**
* The signal strength (0-100).
* Calculated from RSSI on Android.
* Not available on iOS.
*
* @since 7.0.0
*/
signalStrength?: number;
}

Result from isEnabled().

export interface IsEnabledResult {
/**
* Whether Wi-Fi is enabled
*
* @since 7.0.0
*/
enabled: boolean;
}

Permission status.

export interface PermissionStatus {
/**
* Location permission state
*
* @since 7.0.0
*/
location: PermissionState;
}

Options for requesting permissions.

export interface RequestPermissionsOptions {
/**
* Permissions to request
*
* @since 7.0.0
*/
permissions?: 'location'[];
}

Network security types.

export enum NetworkSecurityType {
/**
* Open network with no security
*
* @since 7.0.0
*/
OPEN = 0,
/**
* WEP security
*
* @since 7.0.0
*/
WEP = 1,
/**
* WPA/WPA2 Personal (PSK)
*
* @since 7.0.0
*/
WPA2_PSK = 2,
/**
* WPA/WPA2/WPA3 Enterprise (EAP)
*
* @since 7.0.0
*/
EAP = 3,
/**
* WPA3 Personal (SAE)
*
* @since 7.0.0
*/
SAE = 4,
/**
* WPA3 Enterprise
*
* @since 7.0.0
*/
WPA3_ENTERPRISE = 5,
/**
* WPA3 Enterprise 192-bit mode
*
* @since 7.0.0
*/
WPA3_ENTERPRISE_192_BIT = 6,
/**
* Passpoint network
*
* @since 7.0.0
*/
PASSPOINT = 7,
/**
* Enhanced Open (OWE)
*
* @since 7.0.0
*/
OWE = 8,
/**
* WAPI PSK
*
* @since 7.0.0
*/
WAPI_PSK = 9,
/**
* WAPI Certificate
*
* @since 7.0.0
*/
WAPI_CERT = 10,
}

This page is generated from the plugin’s src/definitions.ts. Re-run the sync when the public API changes upstream.

If you are using Getting Started to plan dashboard and API operations, connect it with Using @capgo/capacitor-wifi for the native capability in Using @capgo/capacitor-wifi, API Overview for the implementation detail in API Overview, Introduction for the implementation detail in Introduction, API Keys for the implementation detail in API Keys, and Devices for the implementation detail in Devices.