useNetworkInformation
Custom hook that tracks the device's network connection status and details (speed, type) using the Network Information API.
Installation
npx sse-tool add use-network-information
npm install sse-hooks
Usage
import { useNetworkInformation } from "./{hooks file}";
const { isOnline, networkInfo } = useNetworkInformation();
if (!isOnline) return <div>You are offline</div>;
return (
<div>
Connection: {networkInfo?.effectiveType} ({networkInfo?.downlink} Mbps)
</div>
);
import { useNetworkInformation } from "sse-hooks";
const { isOnline, networkInfo } = useNetworkInformation();
if (!isOnline) return <div>You are offline</div>;
return (
<div>
Connection: {networkInfo?.effectiveType} ({networkInfo?.downlink} Mbps)
</div>
);
API
Return Value
Returns UseNetworkInformationReturn.
The network state, connection details, and support status.
Changelog
31af5 — Refactor useBattery hook and remove utility functions
c165d — feat: enhance useRoleGuard and useSSR hooks with additional options and documentation
30da4 — feat: add new hooks and their metadata
2f161 — feat: add useConferenceSystem, useKbd, useMediaQuality, useNetworkInformation, usePortal, useRoleGuard, useScreenShare, useSymbol hooks