Skip to content

📡 React Hook to getting and following a browser network online status

License

Notifications You must be signed in to change notification settings

olefirenko/use-network-status

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

📡 React Hook to getting and following a browser network online status

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published