use-network

Get current connection status

Usage

use-network hook returns an object with current connection status:

PropertyValue
Online

Online

rtt
downlink
effectiveType
saveData

false

Browser support

use-network uses experimental navigator.connection, see browser compatibility table.

Definition

function useNetwork(): {
  online: boolean;
  downlink?: number;
  downlinkMax?: number;
  effectiveType?: "slow-2g" | "2g" | "3g" | "4g";
  rtt?: number;
  saveData?: boolean;
  type?:
    | "bluetooth"
    | "cellular"
    | "ethernet"
    | "wifi"
    | "wimax"
    | "none"
    | "other"
    | "unknown";
};