loading
Warning:
Chromium-centric detailsnavigator.connection ships in Chromium-based browsers; Firefox and Safari do not expose it, so every nullable property of the snapshot (EffectiveType, Type, Downlink, DownlinkMax, Rtt, SaveData) comes back null there. Online is backed by navigator.onLine and works everywhere.

Read the connection status

GetStatus

Returns a one-shot snapshot of the network state: online flag, effective connection type (slow-2g, 2g, 3g, 4g), underlying type (wifi, cellular, ethernet, ...), downlink estimates in Mbps, round-trip time in milliseconds and the user's save-data preference. Try it with different throttling profiles in the DevTools Network tab.

C#
var status = await networkInformation.GetStatus();

// status.Online         -> true / false
// status.EffectiveType  -> "slow-2g" | "2g" | "3g" | "4g" | null
// status.Type           -> "wifi" | "cellular" | "ethernet" | ... | null
// status.Downlink       -> estimated Mbps, e.g. 10.0
// status.DownlinkMax    -> maximum advertised Mbps
// status.Rtt            -> round-trip time in ms
// status.SaveData       -> true when reduced data usage is requested
Live sample
status output
Results will appear here when you interact with the samples.

React to connectivity changes

SubscribeChange

SubscribeChange delivers a fresh snapshot whenever connectivity shifts, so you never poll GetStatus. It attaches to the window's online and offline events as well as navigator.connection's change, which means it works on every browser - it just won't report quality changes where IsSupported is false. Test it by toggling the Offline checkbox in the DevTools Network tab (or by disabling your network adapter).

C#
private ButilSubscription? subscription;

subscription = await networkInformation.SubscribeChange(status =>
{
    if (status.Online)
    {
        // back online - refresh data, flush queued work, ...
    }
    else
    {
        // connection lost - switch the UI to offline mode
    }
});

// later
await subscription.DisposeAsync();
Live sample
connectivity output
Results will appear here when you interact with the samples.
Note:
Online is not reachableOnline only means the device has a network attached - a captive portal or a down backend still reports online. Treat a transition as a hint to retry, not as a guarantee that your API is up.

API reference

Member
Signature
Description
GetStatus
ValueTask<NetworkConnectionStatus> GetStatus()
One-shot snapshot of the network state.
SubscribeChange
ValueTask<ButilSubscription> SubscribeChange(Action<NetworkConnectionStatus> handler)
Calls the handler with a fresh snapshot on every connectivity change. Covers online/offline everywhere, plus connection-quality changes on Chromium.
NetworkConnectionStatus.Online
bool Online { get; set; }
True when the user-agent considers itself online (navigator.onLine).
NetworkConnectionStatus.EffectiveType
string? EffectiveType { get; set; }
Effective connection type: slow-2g, 2g, 3g, 4g, or null.
NetworkConnectionStatus.Type
string? Type { get; set; }
Underlying connection type: wifi, cellular, ethernet, etc., or null.
NetworkConnectionStatus.Downlink
double? Downlink { get; set; }
Estimated effective downlink in megabits per second.
NetworkConnectionStatus.DownlinkMax
double? DownlinkMax { get; set; }
Maximum advertised downlink in megabits per second.
NetworkConnectionStatus.Rtt
int? Rtt { get; set; }
Round-trip time estimate in milliseconds.
NetworkConnectionStatus.SaveData
bool? SaveData { get; set; }
True when the user has requested reduced data usage.
An unhandled error has occurred. Reload 🗙