# @jacob-hooks/use-network

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

Latest version **1.0.16** (published 2021-08-12) · MIT license · 0 weekly downloads

## Install

```sh
npm install @jacob-hooks/use-network
pnpm add @jacob-hooks/use-network
yarn add @jacob-hooks/use-network
bun add @jacob-hooks/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.16 |
| Published | 2021-08-12 |
| First published | 2021-08-12 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 4.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Jacob Ko |
| Maintainers | jacobko |
| Keywords | react, hooks, network |

## Links

- npm: https://www.npmjs.com/package/@jacob-hooks/use-network
- Repository: https://github.com/jacobkosmart/custom-hooks
- npm.io page: https://npm.io/package/@jacob-hooks/use-network

## 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.16 (latest) — 2021-08-12
- 1.0.15 — 2021-08-12
- 1.0.14 — 2021-08-12
- 1.0.13 — 2021-08-12
- 1.0.2 — 2021-08-12
- 1.0.0 — 2021-08-12

## README

# @jacob-hooks/use-network

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

## installation

### yarn

`yarn add @jacob-hooks/use-network`

### npm

`npm i @jacob-hooks/use-network`

## Usage

```js
import React from "react";
import useNetwork from "@jacob-hooks/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/@jacob-hooks/use-network · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
