# react-native-network-state

> A lightweight React Native library for monitoring network connectivity and internet reachability with a simple, developer-friendly API.

Latest version **0.1.0** (published 2026-08-19) · MIT license · 0 weekly downloads

## Install

```sh
npm install react-native-network-state
pnpm add react-native-network-state
yarn add react-native-network-state
bun add react-native-network-state
```

## Health

**Score 70/100 (B)** — status: active.

Positive: has types; esm support; no vulnerabilities; recently updated; high maintenance score; high quality score.

Warnings: low downloads; pre 1.0.

## Facts

| | |
|---|---|
| Version | 0.1.0 |
| Published | 2026-08-19 |
| First published | 2026-08-19 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 29.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Reeturaj Thakur |
| Maintainers | reeturajthakur |
| Keywords | react-native, ios, android |

## Links

- npm: https://www.npmjs.com/package/react-native-network-state
- Repository: https://github.com/ReeturajThakur/react-native-network-state
- Homepage: https://github.com/ReeturajThakur/react-native-network-state#readme
- Issues: https://github.com/ReeturajThakur/react-native-network-state/issues
- npm.io page: https://npm.io/package/react-native-network-state

## Alternatives

- [@sindresorhus/slugify](https://npm.io/package/@sindresorhus/slugify.md) — 3.7M weekly downloads
- [solid-js](https://npm.io/package/solid-js.md) — 2.7M weekly downloads
- [expo-glass-effect](https://npm.io/package/expo-glass-effect.md) — 2.5M weekly downloads
- [nanoassert](https://npm.io/package/nanoassert.md) — 780.8K weekly downloads
- [@ffmpeg/ffmpeg](https://npm.io/package/@ffmpeg/ffmpeg.md) — 529.5K weekly downloads

## Recent versions

- 0.1.0 (latest) — 2026-08-19

## README

# react-native-network-state

A lightweight React Native library for monitoring network connectivity and internet reachability with a simple, developer-friendly API.

## Features

- Get the current network state on demand
- Subscribe to connectivity changes in real time
- React hook for components
- Android and iOS support via Turbo Modules (New Architecture)
- Web fallback using `navigator.onLine`

## Installation

```sh
npm install react-native-network-state
```

### iOS

```sh
cd ios && pod install
```

No extra permissions are required on iOS.

### Android

The library automatically adds `ACCESS_NETWORK_STATE` to your app manifest.

## Usage

### Fetch current state

```ts
import { getNetworkState } from 'react-native-network-state';

const state = await getNetworkState();

console.log(state.isConnected); // true | false
console.log(state.isInternetReachable); // true | false | null
console.log(state.type); // 'wifi' | 'cellular' | 'ethernet' | 'none' | 'unknown'
```

### Listen for changes

```ts
import { addNetworkStateListener } from 'react-native-network-state';

const unsubscribe = addNetworkStateListener((state) => {
  console.log('Network changed:', state);
});

// Later
unsubscribe();
```

### React hook

```tsx
import { useNetworkState } from 'react-native-network-state';

function NetworkBanner() {
  const { isConnected, isInternetReachable, type } = useNetworkState();

  if (!isConnected) {
    return <Text>You are offline</Text>;
  }

  if (isInternetReachable === false) {
    return <Text>Connected, but internet is unreachable</Text>;
  }

  return <Text>Online via {type}</Text>;
}
```

## API

### `getNetworkState(): Promise<NetworkState>`

Returns the current network state.

### `addNetworkStateListener(handler): () => void`

Registers a listener for network state changes. Returns an unsubscribe function.

### `useNetworkState(): NetworkState`

React hook that returns the current state and updates automatically.

### `NetworkState`

| Property | Type | Description |
| --- | --- | --- |
| `isConnected` | `boolean` | Whether a network interface is available |
| `isInternetReachable` | `boolean \| null` | Whether the internet is reachable (`null` while checking) |
| `type` | `NetworkType` | Connection type: `wifi`, `cellular`, `ethernet`, `none`, or `unknown` |

## Requirements

- React Native 0.76+
- New Architecture enabled (Turbo Modules)

## Contributing

- [Development workflow](CONTRIBUTING.md#development-workflow)
- [Sending a pull request](CONTRIBUTING.md#sending-a-pull-request)
- [Code of conduct](CODE_OF_CONDUCT.md)

## License

MIT

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