use-network-status
v0.1.3
Published
React hook `useNetworkStatus()` returns whether the client's browser online with updates when the network state is changed.
Downloads
114
Readme
📡 React Hook to get the online status of the browser
React hook useNetworkStatus()
returns whether the client's browser online with updates when the network state is changed.
Installation
The easiest way to use useNetworkStatus
React hook is to install it from npm or yarn.
npm install use-network-status --save
Or
yarn add use-network-status
Usage
Pull the hook into your component (usually the root one) and call the hook inside the functional component.
import { useNetworkStatus } from "use-network-status";
function App() {
const isOnline = useNetworkStatus();
return (
<div className="status">
{isOnline ? '📡 Online' : '📴 Offline'}
</div>
);
}