//#region src/hooks/useNetworkStatus/useNetworkStatus.d.ts
/**
* Effective connection type based on Network Information API
* @see https://wicg.github.io/netinfo/#effective-connection-types
*/
type EffectiveConnectionType = 'slow-2g' | '2g' | '3g' | '4g';
/**
* Physical connection type
* @see https://wicg.github.io/netinfo/#dom-connectiontype
*/
type ConnectionType = 'bluetooth' | 'cellular' | 'ethernet' | 'mixed' | 'none' | 'other' | 'unknown' | 'wifi' | 'wimax';
/**
* Network status information from Network Information API
*/
type NetworkStatus = {
/** Effective connection type (4g, 3g, 2g, slow-2g) - undefined if API not supported */
effectiveType?: EffectiveConnectionType;
/** Physical connection type (wifi, cellular, etc.) - undefined if API not supported */
type?: ConnectionType;
/** Downlink speed in Mbps - undefined if API not supported */
downlink?: number;
/** Round-trip time in milliseconds - undefined if API not supported */
rtt?: number;
/** User's data saver preference - undefined if API not supported */
saveData?: boolean;
};
/**
* @description
* `useNetworkStatus` is a React hook that provides access to the Network Information API.
* It provides raw network connection data. Returns undefined for all properties
* if the API is not supported (e.g., Safari, Firefox).
*
* **Browser Support**:
* - Chrome/Edge (Android): Full support
* - Chrome/Edge (Desktop): Partial support (effectiveType, downlink, rtt, saveData)
* - Firefox: Not supported
* - Safari: Not supported
*
* @returns {NetworkStatus} Network status information
* - `effectiveType` - Connection quality: 'slow-2g' | '2g' | '3g' | '4g'
* - `type` - Physical connection: 'wifi' | 'cellular' | 'ethernet' | etc.
* - `downlink` - Downlink speed in Mbps
* - `rtt` - Round-trip time in milliseconds
* - `saveData` - User's data saver preference
*
* @example
* function AdaptiveImage() {
* const { effectiveType, saveData } = useNetworkStatus();
*
* // Determine quality based on your app's needs
* const useHighQuality = effectiveType === '4g' && !saveData;
*
* return (
*
* );
* }
*
* @example
* function VideoPlayer() {
* const { type, downlink } = useNetworkStatus();
*
* // Custom logic: only autoplay on wifi with good bandwidth
* const shouldAutoplay = type === 'wifi' && (downlink ?? 0) > 5;
*
* return ;
* }
*
* @see https://wicg.github.io/netinfo/
* @see https://developer.mozilla.org/en-US/docs/Web/API/Network_Information_API
*/
declare function useNetworkStatus(): NetworkStatus;
//#endregion
export { ConnectionType, EffectiveConnectionType, NetworkStatus, useNetworkStatus };
//# sourceMappingURL=useNetworkStatus.d.cts.map