# react-use-online-status

> React hook which detects native online status changes and supports polling for more accurate network statuses.

Latest version **1.2.2** (published 2020-11-25) · MIT license · 0 weekly downloads

## Install

```sh
npm install react-use-online-status
pnpm add react-use-online-status
yarn add react-use-online-status
bun add react-use-online-status
```

## Health

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

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.2.2 |
| Published | 2020-11-25 |
| First published | 2020-11-24 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 10.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Sem Postma |
| Maintainers | afirus |
| Keywords | react-use-online-status, keyboard, shortcut, react, hook, hotkey |

## Links

- npm: https://www.npmjs.com/package/react-use-online-status
- Repository: https://github.com/sempostma/react-use-online-status
- Issues: https://github.com/sempostma/react-use-online-status/issues
- npm.io page: https://npm.io/package/react-use-online-status

## Dependencies (1)

- [@types/lodash](https://npm.io/package/@types/lodash.md) ^4.14.165

## 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.2.2 (latest) — 2020-11-25
- 1.1.2 — 2020-11-25
- 0.1.2 — 2020-11-25
- 0.1.1 — 2020-11-24

## README

# react-use-online-status

React hook which detects native online status changes and supports polling for more accurate network statuses.

## Install 

```bash
npm install --save react-use-online-status
```

## Usage

```javascript
import useOnlineStatus from 'react-use-online-status'

const FunctionalComponent = props => {
    const isOnline = useOnlineStatus()

    return (
        <p>Is online: {isOnline ? 'Yes' : 'No'}</p>
    )
}
```

## Advanced usecase

```javascript
import useOnlineStatus from 'react-use-online-status'

const FunctionalComponent = props => {
    const isOnline = useOnlineStatus('/polling-url' || 'https://google.com/generate_204', { 
        interval: 10 * 1000, /* ten seconds (default) */ 
        timeout: 10 * 1000, /* ten seconds (default) */
        method: 'GET' /* (default)
    })

    return (
        <p>Is online: {isOnline ? 'Yes' : 'No'}</p>
    )
}
```

## License

License: MIT

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