Loading...
Please waitLoading...
Please waitMonitor the network status (online/offline) and connection type (WiFi, cellular) with the useNetworkStatus hook, providing a way to adapt functionality based on network conditions.
Status: Offline
pnpm dlx uselab@latest add use-network-status
import { useNetworkStatus } from "@/hooks/use-network-status"
export function Component() {
const { online, effectiveType, downlink } = useNetworkStatus()
return (
<div>
<p>Online: {online ? "Yes" : "No"}</p>
<p>Connection Type: {effectiveType}</p>
<p>Downlink Speed: {downlink} Mbps</p>
</div>
)
}| Name | Type | Description |
|---|---|---|
online | boolean | Indicates if the device is online. |
effectiveType | string | The type of network connection (e.g., 'wifi', 'cellular'). |
downlink | number | The effective bandwidth estimate in Mbps. |