@capgo/capacitor-wifi

中文文档
8.5.9发布于 2026/10/15MPL-2.0TypeScriptESM + CJS零依赖构建来源已验证近 30 天下载 5.3万

Manage WiFi connectivity for your Capacitor app

原始使用文档
文档目录28 节
  1. ➡️ Get started for free
  2. Key features
  3. Why Capacitor WiFi?
  4. Documentation
  5. Compatibility
  6. Install
  7. Requirements
  8. API
  9. addNetwork(...)
  10. connect(...)
  11. disconnect(...)
  12. getAvailableNetworks()
  13. getIpAddress()
  14. getRssi()
  15. getSsid()
  16. getWifiInfo()
  17. isEnabled()
  18. startScan()
  19. checkPermissions()
  20. requestPermissions(...)
  21. addListener('networksScanned', ...)
  22. removeAllListeners()
  23. isNetworkSaved(...)
  24. shareNetwork(...)
  25. getPluginVersion()
  26. Interfaces
  27. Type Aliases
  28. Enums

@capgo/capacitor-wifi

Manage Wi-Fi from your Capacitor app: connect to networks, read the current SSID, IP and signal, and scan nearby networks on Android.

Capgo - Build Capacitor apps with AI, ship updates instantly

Capgo: push fixes to your Capacitor users in minutes, build signed iOS and Android apps without a Mac, and roll back in one click.

➡️ Get started for free

14-day unlimited free trial. No credit card required

🤖 Building with an AI coding agent? Install Capgo skills so Claude Code, Codex, Cursor, Copilot, or Gemini CLI know how to install and use @capgo/capacitor-wifi in your Capacitor app: npx skills add Cap-go/capgo-skills. Then ask your agent: "Add @capgo/capacitor-wifi to my Capacitor app and wire it up." Agent setup guides · Hosted MCP

@capgo/capacitor-wifi for Capacitor apps

Key features

  • Connect: connect(), addNetwork() and disconnect().
  • Current network: getSsid(), getIpAddress() and getWifiInfo().
  • Scanning on Android: startScan(), getAvailableNetworks(), getRssi() and the networksScanned event.
  • Saved networks and sharing: isNetworkSaved() and shareNetwork().
  • Permissions: location permission helpers. On Android, scans, SSID, RSSI and getWifiInfo() need location permission.
  • Platforms: iOS and Android. iOS uses NetworkExtension hotspot configuration, so some calls are Android only. Not available on web.

Why Capacitor WiFi?

A free and powerful WiFi management plugin with modern platform support:

  • Network management - Connect, disconnect, and add WiFi networks programmatically
  • Network scanning - Discover available WiFi networks (Android only)
  • Network info - Get SSID, IP address, and signal strength (RSSI)
  • Modern APIs - Uses NetworkExtension (iOS) and handles Android 10+ restrictions
  • Cross-platform - Consistent API across iOS and Android

Perfect for IoT apps, network diagnostic tools, and smart home applications.

Documentation

The most complete doc is available here: https://capgo.app/docs/plugins/wifi/

Compatibility

Plugin versionCapacitor compatibilityMaintained
v8.*.*v8.*.*✅
v7.*.*v7.*.*On demand
v6.*.*v6.*.*❌
v5.*.*v5.*.*❌

Note: The major version of this plugin follows the major version of Capacitor. Use the version that matches your Capacitor installation (e.g., plugin v8 for Capacitor 8). Only the latest major version is actively maintained.

Install

You can use our AI-Assisted Setup to install the plugin. Add the Capgo skills to your AI tool using the following command:

npx skills add https://github.com/cap-go/capacitor-skills --skill capacitor-plugins

Then use the following prompt:

Use the `capacitor-plugins` skill from `cap-go/capacitor-skills` to install the `@capgo/capacitor-wifi` plugin in my project.

If you prefer Manual Setup, install the plugin by running the following commands and follow the platform-specific instructions below:

npm install @capgo/capacitor-wifi
npx cap sync

Requirements

  • iOS: Requires location permission (NSLocationWhenInUseUsageDescription in Info.plist) to access WiFi information. Uses NetworkExtension framework.
  • Android: Requires location permissions. Network scanning and RSSI available on Android only. Android 10+ uses system dialogs for adding networks.

API

WiFi plugin for managing device WiFi connectivity

addNetwork(...)

addNetwork(options: AddNetworkOptions) => Promise<void>

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.

ParamTypeDescription
optionsAddNetworkOptions- Network configuration options

Since: 7.0.0


connect(...)

connect(options: ConnectOptions) => Promise<void>

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.

Resolves only after the device is confirmed associated with the requested SSID. On failure, rejects with a Capacitor error that includes a stable code from {@link WifiConnectionErrorCode}. Prefer error.code over parsing error.message. Specific codes are returned only when the native OS provides that reason; otherwise the plugin returns CONNECTION_FAILED.

ParamTypeDescription
optionsConnectOptions- Connection options

Since: 7.0.0


disconnect(...)

disconnect(options?: DisconnectOptions | undefined) => Promise<void>

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

ParamTypeDescription
optionsDisconnectOptions- Optional disconnect options

Since: 7.0.0


getAvailableNetworks()

getAvailableNetworks() => Promise<GetAvailableNetworksResult>

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

Returns: Promise<GetAvailableNetworksResult>

Since: 7.0.0


getIpAddress()

getIpAddress() => Promise<GetIpAddressResult>

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

Returns: Promise<GetIpAddressResult>

Since: 7.0.0


getRssi()

getRssi() => Promise<GetRssiResult>

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

Returns: Promise<GetRssiResult>

Since: 7.0.0


getSsid()

getSsid() => Promise<GetSsidResult>

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

Returns: Promise<GetSsidResult>

Since: 7.0.0


getWifiInfo()

getWifiInfo() => Promise<WifiInfo>

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.

Returns: Promise<WifiInfo>

Since: 7.0.0


isEnabled()

isEnabled() => Promise<IsEnabledResult>

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

Returns: Promise<IsEnabledResult>

Since: 7.0.0


startScan()

startScan() => Promise<void>

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.

Since: 7.0.0


checkPermissions()

checkPermissions() => Promise<PermissionStatus>

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

Returns: Promise<PermissionStatus>

Since: 7.0.0


requestPermissions(...)

requestPermissions(options?: RequestPermissionsOptions | undefined) => Promise<PermissionStatus>

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

ParamTypeDescription
optionsRequestPermissionsOptions- Optional permission request options

Returns: Promise<PermissionStatus>

Since: 7.0.0


addListener('networksScanned', ...)

addListener(eventName: 'networksScanned', listenerFunc: () => void) => Promise<PluginListenerHandle>

Add a listener for the 'networksScanned' event. Only available on Android. This event is fired when Wi-Fi scan results are available.

ParamTypeDescription
eventName'networksScanned'- The event name ('networksScanned')
listenerFunc() => void- The callback function to execute

Returns: Promise<PluginListenerHandle>

Since: 7.0.0


removeAllListeners()

removeAllListeners() => Promise<void>

Remove all listeners for this plugin.

Since: 7.0.0


isNetworkSaved(...)

isNetworkSaved(options: IsNetworkSavedOptions) => Promise<IsNetworkSavedResult>

Check whether a network with the given SSID has already been saved/configured by this app. On Android SDK 30+, this checks the app's Wi-Fi network suggestions. On older Android (including SDK 29), this checks the system's configured networks list. On iOS, this checks the hotspot configurations managed by this app. Use this to decide whether to call addNetwork() (first time) or connect() (already saved).

ParamTypeDescription
optionsIsNetworkSavedOptions- Options containing the SSID to check

Returns: Promise<IsNetworkSavedResult>

Since: 8.2.0


shareNetwork(...)

shareNetwork(options?: ShareNetworkOptions | undefined) => Promise<ShareNetworkResult>

Share Wi-Fi network credentials using platform-native sharing flows.

On Android 10+, this uses Wi-Fi Easy Connect (DPP). When dppUri is provided, the system provisions credentials to the target device. Otherwise, it opens the system UI to share the current or specified network (optionally via QR code when ssid and password are provided).

On iOS 26.2+, this uses the Wi-Fi Infrastructure framework with a paired AccessorySetupKit accessory. The host app must pair the accessory first and pass its bluetoothIdentifier or accessoryIdentifier. The app also needs the com.apple.developer.wifi-infrastructure entitlement.

ParamTypeDescription
optionsShareNetworkOptions- Sharing options

Returns: Promise<ShareNetworkResult>

Since: 8.4.0


getPluginVersion()

getPluginVersion() => Promise<{ version: string; }>

Get the native plugin version.

Returns: Promise<{ version: string; }>

Since: 7.0.0


Interfaces

AddNetworkOptions

Options for adding a network

PropTypeDescriptionDefaultSince
ssidstringThe SSID of the network to add7.0.0
passwordstringThe password for the network (optional for open networks)7.0.0
isHiddenSsidbooleanWhether the network is hidden (Android only)false7.0.0
securityTypeNetworkSecurityTypeThe security type of the network (Android only)NetworkSecurityType.WPA2_PSK7.0.0

ConnectOptions

Options for connecting to a network

PropTypeDescriptionDefaultSince
ssidstringThe SSID of the network to connect to7.0.0
passwordstringThe password for the network (optional for open networks)7.0.0
isHiddenSsidbooleanWhether the network is hidden (Android only)false7.0.0
autoRouteTrafficbooleanWhether 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.false7.0.0
timeoutMsnumberMaximum time in milliseconds to wait for confirmation that the device is associated with the requested SSID before rejecting with CONNECTION_TIMEOUT. Must be a positive number when provided.300008.5.0

DisconnectOptions

Options for disconnecting from a network

PropTypeDescriptionSince
ssidstringThe SSID of the network to disconnect from (optional)7.0.0

GetAvailableNetworksResult

Result from getAvailableNetworks()

PropTypeDescriptionSince
networksNetwork[]List of available networks7.0.0

Network

Represents a Wi-Fi network

PropTypeDescriptionSince
ssidstringThe SSID of the network7.0.0
rssinumberThe signal strength in dBm7.0.0
securityTypesNetworkSecurityType[]The security types supported by this network (Android SDK 33+ only)7.0.0

GetIpAddressResult

Result from getIpAddress()

PropTypeDescriptionSince
ipAddressstringThe device's IP address7.0.0

GetRssiResult

Result from getRssi()

PropTypeDescriptionSince
rssinumberThe signal strength in dBm7.0.0

GetSsidResult

Result from getSsid()

PropTypeDescriptionSince
ssidstringThe SSID of the current network7.0.0

WifiInfo

Comprehensive WiFi information

PropTypeDescriptionSince
ssidstringThe SSID (network name) of the current network7.0.0
bssidstringThe BSSID (MAC address) of the access point. Not available on iOS.7.0.0
ipstringThe device's IP address on the network7.0.0
frequencynumberThe network frequency in MHz. Not available on iOS.7.0.0
linkSpeednumberThe connection speed in Mbps. Not available on iOS.7.0.0
signalStrengthnumberThe signal strength (0-100). Calculated from RSSI on Android. Not available on iOS.7.0.0

IsEnabledResult

Result from isEnabled()

PropTypeDescriptionSince
enabledbooleanWhether Wi-Fi is enabled7.0.0

PermissionStatus

Permission status

PropTypeDescriptionSince
locationPermissionStateLocation permission state7.0.0

RequestPermissionsOptions

Options for requesting permissions

PropTypeDescriptionSince
permissions'location'[]Permissions to request7.0.0

PluginListenerHandle

PropType
remove() => Promise<void>

IsNetworkSavedResult

Result from isNetworkSaved()

PropTypeDescriptionSince
isSavedbooleanWhether the network has already been saved/configured by this app8.2.0

IsNetworkSavedOptions

Options for checking whether a network is saved

PropTypeDescriptionSince
ssidstringThe SSID of the network to check8.2.0

ShareNetworkResult

Result from shareNetwork()

PropTypeDescriptionSince
startedbooleanWhether the platform sharing flow was started or completed.8.4.0
authorizationStateWifiSharingAuthorizationStateiOS: Authorization state after requestAuthorization, when requested.8.4.0
askToShareStateWifiSharingAskStateiOS: Result of askToShare when requested.8.4.0

ShareNetworkOptions

Options for sharing Wi-Fi network credentials

PropTypeDescriptionDefaultSince
dppUristringAndroid: Wi-Fi Easy Connect (DPP) URI from the target device. When provided, launches the system UI to provision Wi-Fi credentials to that device.8.4.0
ssidstringNetwork SSID to share via QR code on Android. When omitted, the system uses the currently connected network when possible.8.4.0
passwordstringNetwork password for QR code sharing on Android. Required when sharing a specific WPA/WPA2/WPA3 network via QR code. iOS does not allow reading saved Wi-Fi passwords from the system.8.4.0
bluetoothIdentifierstringiOS 26.2+: Bluetooth identifier of a paired AccessorySetupKit accessory. Required for Wi-Fi Infrastructure network sharing on iOS unless accessoryIdentifier is set.8.4.0
accessoryIdentifierstringiOS 26.2+: Accessory UUID from AccessorySetupKit. Alternative lookup key when bluetoothIdentifier is unavailable.8.4.0
requestAuthorizationbooleaniOS 26.2+: Request initial Wi-Fi network sharing authorization for the accessory.false8.4.0
askToSharebooleaniOS 26.2+: Prompt the user to share the current Wi-Fi network with the accessory.true8.4.0

Type Aliases

PermissionState

'prompt' | 'prompt-with-rationale' | 'granted' | 'denied'

WifiSharingAuthorizationState

Authorization state returned by iOS Wi-Fi Infrastructure sharing

'authorized' | 'denied' | 'notDetermined' | 'unsupported'

WifiSharingAskState

Result state returned by iOS Wi-Fi Infrastructure askToShare()

'shared' | 'declined' | 'cancelled' | 'notNeeded' | 'unsupported'

Enums

NetworkSecurityType

MembersValueDescriptionSince
OPEN0Open network with no security7.0.0
WEP1WEP security7.0.0
WPA2_PSK2WPA/WPA2 Personal (PSK)7.0.0
EAP3WPA/WPA2/WPA3 Enterprise (EAP)7.0.0
SAE4WPA3 Personal (SAE)7.0.0
WPA3_ENTERPRISE5WPA3 Enterprise7.0.0
WPA3_ENTERPRISE_192_BIT6WPA3 Enterprise 192-bit mode7.0.0
PASSPOINT7Passpoint network7.0.0
OWE8Enhanced Open (OWE)7.0.0
WAPI_PSK9WAPI PSK7.0.0
WAPI_CERT10WAPI Certificate7.0.0

版本与发布记录

@capgo/capacitor-wifi 共发布 41 个版本,首次发布于 2025/11/19;过去 12 个月发布了 41 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
8.5.9latest2026/10/1525 天前
8.5.82026/10/1327 天前
8.5.72026/10/1327 天前
8.5.62026/10/091 个月前
8.5.52026/10/081 个月前
8.5.42026/09/161 个月前

其他发布通道:beta → 8.5.0-beta.pr20.13.1。

关于 @capgo/capacitor-wifi 的常见问题

@capgo/capacitor-wifi 是什么?

Manage WiFi connectivity for your Capacitor app

如何安装 @capgo/capacitor-wifi?

在项目目录运行 npm install @capgo/capacitor-wifi,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:@capacitor/core(>=8.0.0)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@capgo/capacitor-wifi 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@capgo/capacitor-wifi 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@capgo/capacitor-wifi 可以商用吗?

@capgo/capacitor-wifi 使用 MPL-2.0 许可。弱 Copyleft:可以商用,也可以和闭源代码一起使用;但如果分发时修改了 MPL 授权的文件,这些文件的修改需以 MPL 开源。以上为概括,不构成法律意见,请以许可原文为准。

@capgo/capacitor-wifi 的下载量有多少?

根据 npm 官方下载统计,@capgo/capacitor-wifi 在 2026/10/09 – 2026/11/07 这 30 天内被下载 53,105 次,日均约 1,770 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@capgo/capacitor-wifi 还在维护吗?

最新版本 8.5.9 发布于 2026/10/15(25 天前);至今共发布 41 个版本,其中过去 12 个月发布了 41 个;首次发布于 2025/11/19。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。