# @loyhooks/use-network

> React Hook to listen when the user goes online or offline.

Latest version **1.0.1** (published 2019-06-06) · MIT license · 0 weekly downloads

## Install

```sh
npm install @loyhooks/use-network
pnpm add @loyhooks/use-network
yarn add @loyhooks/use-network
bun add @loyhooks/use-network
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.1 |
| Published | 2019-06-06 |
| First published | 2019-06-06 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 2.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | LEE ON YOU |
| Maintainers | loy124 |
| Keywords | hooks, react, online, offline |

## Links

- npm: https://www.npmjs.com/package/@loyhooks/use-network
- Repository: https://github.com/loy124/LoyHooks
- Homepage: https://github.com/loy124/LoyHooks#readme
- Issues: https://github.com/loy124/LoyHooks/issues
- npm.io page: https://npm.io/package/@loyhooks/use-network

## Dependencies (2)

- [react](https://npm.io/package/react.md) ^16.8.6
- [react-dom](https://npm.io/package/react-dom.md) ^16.8.6

## Alternatives

- [mobx-react](https://npm.io/package/mobx-react.md) — 2.8M weekly downloads
- [rc-tree](https://npm.io/package/rc-tree.md) — 2.6M weekly downloads
- [@react-oauth/google](https://npm.io/package/@react-oauth/google.md) — 1.3M weekly downloads
- [@wagmi/connectors](https://npm.io/package/@wagmi/connectors.md) — 877.0K weekly downloads
- [vee-validate](https://npm.io/package/vee-validate.md) — 836.4K weekly downloads

## Recent versions

- 1.0.1 (latest) — 2019-06-06
- 1.0.0 — 2019-06-06

## README

# @loyhooks/use-network

React Hook to listen when the user goes online or offline.

## Installation

#### yarn

`yarn add @loyhooks/use-network`

#### npm

`npm i @loyhooks/use-network`

## Usage

```js
import React from "react";
import useNetwork from "@loyhooks/use-network";

function App() {
  const onNetworkChange = isOnline =>
    console.log(isOnline ? "We are back online" : "We just got offline");
  const isOnline = useNetwork(onNetworkChange);
  return <h1>{isOnline ? "We are online" : "We are offline"}</h1>;
}
```

### Arguments

| Argument        | Type     | Description                                           | Arguments          | Required |
| --------------- | -------- | ----------------------------------------------------- | ------------------ | -------- |
| onNetworkChange | function | Function to be called when the network status changes | isOnline : Boolean | no       |

### Return

| Return value | Type    | Description                                         | Default value |
| ------------ | ------- | --------------------------------------------------- | ------------- |
| isOnline     | Boolean | A boolean representing if the user is online or not | true          |

---
_Source: https://npm.io/package/@loyhooks/use-network · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
