use-network-status
TypeScript icon, indicating that this package has built-in type declarations

0.1.3 • Public • Published

📡 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>
  );
}

Dependents (0)

Package Sidebar

Install

npm i use-network-status

Weekly Downloads

30

Version

0.1.3

License

MIT

Unpacked Size

11.4 kB

Total Files

12

Last publish

Collaborators

  • olefirenko