Skip to main content
@capgo/capacitor-network-diagnostics Developer Tools Open source

Network Diagnostics Capacitor plugin

Run native network diagnostics for URL reachability, TCP ports, WebSocket handshakes, speed, and packet loss

Install

bun add @capgo/capacitor-network-diagnostics bunx cap sync
npm, pnpm or yarn
  • npm install @capgo/capacitor-network-diagnostics
  • pnpm add @capgo/capacitor-network-diagnostics
  • yarn add @capgo/capacitor-network-diagnostics

Guide

How to use Network Diagnostics in Capacitor

Using @capgo/capacitor-network-diagnostics

Native network diagnostics for Capacitor apps that need to debug restricted Wi-Fi, captive portals, blocked ports, WebSocket failures, slow downloads, and packet loss.

Install

npm install @capgo/capacitor-network-diagnostics
npx cap sync

What This Plugin Exposes

  • getNetworkStatus - Read the native connection type and platform network flags.
  • testUrl - Check HTTP or HTTPS URL reachability with status code and latency.
  • testPort - Open a native TCP socket to a host and port.
  • testWebSocket - Validate a ws:// or wss:// handshake.
  • testDownloadSpeed - Measure native download throughput.
  • testPacketLoss - Estimate application-level packet loss with repeated probes.
  • runDiagnostics - Run a combined diagnostic pass and return an issue list.

Example Usage

import { NetworkDiagnostics } from '@capgo/capacitor-network-diagnostics';

const report = await NetworkDiagnostics.runDiagnostics({
  urls: [{ url: 'https://api.example.com/health' }],
  ports: [{ host: 'api.example.com', port: 443 }],
  websockets: [{ url: 'wss://ws.example.com/socket' }],
  packetLoss: {
    mode: 'tcp',
    host: 'api.example.com',
    port: 443,
    count: 10,
  },
});

console.log(report.status);
console.log(report.issues);

Support Workflow

Ask the affected user to run diagnostics while connected to the problematic Wi-Fi or access point. Send results to support with:

  • connection type and OS network flags
  • failed URLs, ports, or WebSocket endpoints
  • download Mbps
  • packet loss percentage
  • native error codes and messages

Raw ICMP ping is not portable on iOS and Android apps, so packet loss is measured with repeated TCP or HTTP probes.

Full Reference

FAQ

Network Diagnostics plugin FAQ

How do I install the Network Diagnostics plugin in a Capacitor app?

Run "bun add @capgo/capacitor-network-diagnostics" (or "npm install @capgo/capacitor-network-diagnostics"), then run "bunx cap sync" so the iOS and Android projects pick up the native code. Import it from "@capgo/capacitor-network-diagnostics" in your app code.

Does @capgo/capacitor-network-diagnostics work with React, Vue and Angular?

Yes. Network Diagnostics is a Capacitor package, so it works with any web framework that runs inside Capacitor, including Ionic, React, Vue, Angular, Svelte and plain JavaScript.

Which Capacitor version does @capgo/capacitor-network-diagnostics support?

Capgo plugins follow Capacitor's major version: use the plugin major version that matches your Capacitor major version (for example plugin v8 with Capacitor 8). The compatibility table in the GitHub README lists the maintained versions.

Is @capgo/capacitor-network-diagnostics free and open source?

Yes. The source code is public on GitHub at https://github.com/Cap-go/capacitor-network-diagnostics/ and the package is free to install from npm. Bug reports and pull requests are welcome.

Can I update code that uses Network Diagnostics without an App Store review?

Installing or upgrading the plugin changes native code, so it needs a new store build. After that, JavaScript, HTML and CSS changes that call the plugin can ship instantly with Capgo live updates.

Ship Network Diagnostics changes without waiting for app review

Once the plugin is in your store build, Capgo live updates push your JavaScript, HTML and CSS changes to users in minutes.

Start with Capgo