Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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
- Host: GitHub
- URL: https://github.com/olefirenko/use-network-status
- Owner: olefirenko
- License: mit
- Created: 2020-06-27T01:19:24.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2021-08-18T08:42:24.000Z (over 3 years ago)
- Last Synced: 2024-03-14T21:06:51.582Z (10 months 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'}
);
}
```