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 year ago
JSON representation
📡 React Hook to getting and following a browser network online status
- Host: GitHub
- URL: https://github.com/olefirenko/use-network-status
- Owner: olefirenko
- License: mit
- Created: 2020-06-27T01:19:24.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2021-08-18T08:42:24.000Z (almost 5 years ago)
- Last Synced: 2025-04-14T06:09:17.059Z (about 1 year ago)
- Topics: network, online, react-hooks
- Language: TypeScript
- Homepage:
- Size: 297 KB
- Stars: 4
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
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'}
);
}
```