Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/olefirenko/use-network-status

📡 React Hook to getting and following a browser network online status
https://github.com/olefirenko/use-network-status

network online react-hooks

Last synced: about 1 month ago
JSON representation

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

Awesome Lists containing this project

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**.

```sh
npm install use-network-status --save
```

Or

```sh
yarn add use-network-status
```

## Usage
Pull the hook into your component (usually the root one) and call the hook inside the functional component.

```js
import { useNetworkStatus } from "use-network-status";

function App() {
const isOnline = useNetworkStatus();

return (


{isOnline ? '📡 Online' : '📴 Offline'}

);
}
```