useNetworkState
Handle the NetworkInformation (opens in a new tab) API and the user network connection changes.
Status
Online
warning
Some network informations may not supported in other browsers. checkout Browser compatibility (opens in a new tab)
Type Definitions
type NetworkInformation = {
type?: 'bluetooth' | 'cellular' | 'ethernet' | 'none' | 'wifi' | 'wimax' | 'other' | 'unknown';
rtt?: number;
downlink?: number;
downlinkMax?: number;
effectiveType?: 'slow-2g' | '2g' | '3g' | '4g';
saveData?: boolean;
};
const useNetworkState: () => NetworkInformation & {
isOnline: boolean;
};