NWPathMonitor: what it is, network monitoring and working in iOS

Author: IT Sectr Published: 2026-03-10 Reading time: 9 min

NWPathMonitor is a class from the Network framework in iOS and macOS for monitoring the state of the device’s network path. According to Apple Developer Documentation (2025), NWPathMonitor allows the application to track network availability, determine the interface type, and react to connection changes. NWPathMonitor provides information about the connection type, data costs, and internet availability through a convenient callback with NWPath.

Key Takeaways

  • NWPathMonitor — a class of the Network framework for asynchronous network path monitoring in iOS and macOS.
  • NWPath contains information about network availability, interface type (Wi-Fi, cellular data, Ethernet) and cost status.
  • The start method starts monitoring on the specified dispatch queue, the cancel method stops it.
  • The pathUpdateHandler property — a closure that is called on every change of the network path state.
  • NWPathMonitor supports filtering by required interface type through the requiredInterfaceType parameter.

What is NWPathMonitor?

NWPathMonitor is a class from the Network framework introduced by Apple in iOS 12 and macOS 10.14 Mojave. It provides a modern API for tracking changes in the device’s network path — the combination of network interfaces through which the application’s traffic passes.

Before iOS 12, the Reachability library built on the C-based SystemConfiguration framework was used for network monitoring. NWPathMonitor is a native Swift alternative with a richer API, support for modern connection types (VPN, multipath, LTE, 5G) and built-in GCD integration.

The key difference between NWPathMonitor and Reachability — the NWPath object provides not just a binary “available/unavailable” status, but a complete picture of the path: used interfaces, their priority, costs, roaming status, and proxy and VPN capabilities. The developer gets comprehensive information for making decisions about network requests.

History of the Network framework

The Network framework emerged as a modern replacement for low-level C APIs — CFStream and BSD Sockets. It provides a unified interface for network communication across all Apple platforms, including watchOS and tvOS. NWPathMonitor is part of this framework alongside NWConnection, NWListener and NWBrowser.

The Network framework is written in Swift and uses GCD for asynchronous processing. This means that NWPathMonitor callbacks execute on the specified dispatch queue, integrating with the application’s existing multithreading architecture without manual thread management.

How to Use NWPathMonitor in an Application

Using NWPathMonitor starts with creating a class instance and configuring the pathUpdateHandler callback. Then the start method is called with a dispatch queue where the closure will execute. Monitoring is stopped by the cancel method, which also releases resources.

swift
import Network

class NetworkMonitor {
    private let monitor = NWPathMonitor()
    private let queue = DispatchQueue("monitor")

    func startMonitoring() {
        monitor.pathUpdateHandler = { path in
            if path.status == .satisfied {
                print("Network available")
            } else {
                print("Network unavailable")
            }
        }
        monitor.start(on: queue)
    }

    func stopMonitoring() {
        monitor.cancel()
    }
}

Working with Interface Type

NWPathMonitor can be configured to monitor only a specific interface type. Use the initializer NWPathMonitor(requiredInterfaceType:) with the NWInterface.InterfaceType parameter — .wifi, .cellular, .wiredEthernet or .loopback. If no type is specified, monitoring covers all interfaces.

Practical example: a streaming application can monitor only Wi-Fi and warn the user about switching to cellular data. Checking isConstrained and isExpensive in NWPath allows determining whether the current connection is metered or speed-limited.

Monitoring Lifecycle

Monitoring should start at application launch or when entering the foreground, and stop when entering the background. It is recommended to create one NWPathMonitor instance for the entire application (singleton) and use it from different modules through a protocol or service layer.

NWPath Properties and Capabilities

NWPath is an object passed to the pathUpdateHandler that describes the current state of the network path. It contains five key properties covering most network monitoring scenarios. NWPath.Status — an enumeration with three states: satisfied (available), unsatisfied (unavailable), and requiresConnection (needs connection).

PropertyTypeDescription
statusNWPath.StatusCurrent path state: satisfied, unsatisfied, requiresConnection
availableInterfaces[NWInterface]List of all available network interfaces
gateways[NWEndpoint]List of gateways used for routing
isExpensiveBoolTrue if the connection is metered (cellular data, personal hotspot)
isConstrainedBoolTrue if the connection is speed-limited (Low Data Mode)

Checking Costs and Restrictions

The isExpensive property is a critical flag for applications working with large amounts of data. If isExpensive = true, the application should reduce streaming quality, postpone update downloads, or warn the user. isConstrained indicates that Low Data Mode is enabled.

To check internet availability (not just network), use the usesInterfaceType method. If the device is connected to Wi-Fi without internet — NWPath may show satisfied, but actual access is absent. In such cases, additional validation via NWConnection is required.

NWPathMonitor Implementation Examples

Let’s look at an advanced NWPathMonitor implementation with cost handling, interface types, and ViewModel notification through a publisher. The example uses the Combine framework for reactive UI updates when the network state changes.

swift
import Network
import Combine

final class NetworkManager: ObservableObject {
    static let shared = NetworkManager()
    @Published private(set) var isConnected = true
    @Published private(set) var isExpensive = false

    private let monitor = NWPathMonitor()
    private let queue = DispatchQueue("NetworkMonitor")

    private init() {
        monitor.pathUpdateHandler = { [weak self] path in
            DispatchQueue.main.async {
                self?.isConnected = path.status == .satisfied
                self?.isExpensive = path.isExpensive
            }
        }
        monitor.start(on: queue)
    }

    func checkInterface() -> NWInterface.InterfaceType {
        let path = monitor.currentPath
        if path.usesInterfaceType(.wifi) { return .wifi }
        if path.usesInterfaceType(.cellular) { return .cellular }
        return .other
    }
}

Handling Network Loss with Deferred Action

When a connection is lost, you may need not only to notify the UI but also to perform deferred actions — for example, save a draft request for later sending. Implement a queue of deferred requests that accumulates operations during unsatisfied status and sends them when satisfied is restored.

The ReachabilityManager with a delegate pattern is ideal for this task: NWPathMonitor notifies the manager, the manager updates the queue and UI. When the status changes to satisfied, the queue automatically flushes, and the UI receives a connection restoration indication.

NWPathMonitor vs Reachability

Before NWPathMonitor, the standard solution for network monitoring in iOS was Apple’s Reachability library (example from documentation), built on SystemConfiguration. The main differences: Reachability works through SCNetworkReachability in C, does not support modern network types, and only provides a binary availability response.

NWPathMonitor addresses these limitations: it is written in Swift, supports VPN, multipath, 5G and LTE, provides detailed information about each interface, and works asynchronously through GCD. Reachability is still used in projects with minimum iOS 11 and below support.

CharacteristicNWPathMonitorReachability
Minimum VersioniOS 12iOS 2
LanguageSwift (Network)C (SystemConfiguration)
Interface TypesWi-Fi, Cellular, Ethernet, VPNWi-Fi, WWAN (generic)
isExpensiveYesNo
AsyncGCD (dispatch queue)RunLoop
Multiple InterfacesYes (multipath)No

When to Use Reachability

If your application supports iOS 11 and below, Reachability remains the only option. For iOS 12+ projects, it is recommended to use NWPathMonitor directly — it integrates better with modern Swift code, Combine, and SwiftUI.

Migration from Reachability to NWPathMonitor is straightforward: simply replace SCNetworkReachability calls with NWPathMonitor, preserving the same handling logic. An abstraction layer (NetworkMonitorProtocol) will allow switching between implementations without changing the application’s business logic.

Frequently Asked Questions

What is the minimum iOS version required for NWPathMonitor?

NWPathMonitor is available starting from iOS 12.0, macOS 10.14, watchOS 5.0 and tvOS 12.0. For projects supporting older versions, use Reachability from SystemConfiguration or wrapper libraries with conditional compilation via #available.

How is NWPath.Status.satisfied different from unsatisfied?

Satisfied means that traffic can pass through at least one interface. Unsatisfied — no interface is available. The requiresConnection state — the path requires establishing a connection (e.g., VPN is not connected), and traffic temporarily cannot pass.

How to determine network type — Wi-Fi or cellular?

Use the usesInterfaceType method on NWPath: path.usesInterfaceType(.wifi) for Wi-Fi, path.usesInterfaceType(.cellular) for cellular data. The method returns true if the current traffic passes through the specified interface type.

Should I cancel NWPathMonitor when entering the background?

It is recommended to pause monitoring in the background to save battery. Calling monitor.cancel() in applicationDidEnterBackground and restarting start in applicationWillEnterForeground reduce power consumption. Use Background Task for critical operations.

How to handle captive portals with NWPathMonitor?

NWPathMonitor may show satisfied even with a captive portal. To determine actual internet access, perform an HTTP request to a trusted endpoint via NWConnection. If a redirect occurs — the portal is active and requires authorization in a WebView.

Summary

  • NWPathMonitor — a class of the Network framework for monitoring the network path in iOS 12+ with GCD and Combine support.
  • NWPath contains complete information about the connection: status, interface types, costs, constraints, and gateways.
  • The start method launches monitoring on the specified queue, pathUpdateHandler receives NWPath updates.
  • The isExpensive and isConstrained properties allow identifying metered and restricted connections.
  • NWPathMonitor replaced Reachability for iOS 12+, providing a richer Swift API.
  • Interface type filtering is implemented via the initializer with the requiredInterfaceType parameter.
  • For background operation, monitoring should be paused and resumed when switching between foreground and background.

We will develop a mobile application turnkey

IT Sectr creates iOS and Android applications for startups and businesses since 2017. We will advise you and propose the best solution.

Discuss the project

Read also