npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

react-native-network-status

v1.0.12

Published

A React Native library to monitor network status

Readme

react-native-network-status

A lightweight, easy-to-use library for monitoring network connectivity in React Native applications. Built on top of @react-native-community/netinfo, this library provides a simple hook and utility functions to track network status with minimal setup.

Features

  • Simple Hook: Use useNetworkStatus to get real-time network updates in functional components.
  • Manual Fetch: Use getNetworkStatus to check the current network state on demand.
  • Consistent API: Returns a predictable { isConnected, type } object.
  • Lightweight: Minimal abstraction over NetInfo for ease of use without bloat.
  • Configurable: Customize underlying NetInfo settings if needed.

Installation

  1. Install the library via npm:
    npm install react-native-network-status
  2. Install the library via npm:
    Ensure the peer dependency `@react-native-community/netinfo` is installed and linked:

For React Native 0.60+, autolinking handles the rest. For older versions, follow the NetInfo setup guide.

Usage

  • Hook: useNetworkStatus

Monitor network status in real time with the useNetworkStatus hook:

import React from "react";
import { Text, View } from "react-native";
import { useNetworkStatus } from "react-native-network-status";

const MyComponent = () => {
  const { isConnected, type } = useNetworkStatus();

  return (
    <View>
      <Text>
        Status:{" "}
        {isConnected === null
          ? "Checking..."
          : isConnected
          ? "Online"
          : "Offline"}
      </Text>
      <Text>Connection Type: {type}</Text>
    </View>
  );
};

export default MyComponent;
  • isConnected: boolean | null - true if connected, false if not, null while loading initial state.

  • type: string - Network type (e.g., wifi, cellular, none, unknown).

Function: getNetworkStatus

Fetch the current network status manually:

import { getNetworkStatus } from "react-native-network-status";

const checkNetwork = async () => {
  const status = await getNetworkStatus();
  console.log(status); // { isConnected: true, type: 'wifi' }
};

Returns a promise resolving to { isConnected, type }.

Configuration: configureNetworkStatus

Optionally configure the underlying NetInfo behaviour:

import { configureNetworkStatus } from "react-native-network-status";

configureNetworkStatus({
  reachabilityUrl: "https://my-custom-endpoint.com",
  reachabilityTest: (response) => response.status === 200,
});

See the NetInfo configuration docs for all options.

Why Use This Library?

Unlike @react-native-community/netinfo, which provides a low-level API requiring manual subscription and state management, react-native-network-status offers:

  • A React hook for seamless integration with modern React Native apps.
  • A simplified API focused on the most common use cases (isConnected and type).
  • Less boilerplate, faster setup, and a consistent return shape.

If you need advanced features or raw control, consider using NetInfo directly. For quick and easy network status tracking, this library is your go-to solution.

Example App

Here’s a full example combining the hook and manual fetch:

import React from "react";
import { Text, View, Button } from "react-native";
import {
  useNetworkStatus,
  getNetworkStatus,
} from "react-native-network-status";

const App = () => {
  const { isConnected, type } = useNetworkStatus();

  const checkManually = async () => {
    const status = await getNetworkStatus();
    alert(`Connected: ${status.isConnected}, Type: ${status.type}`);
  };

  return (
    <View style={{ flex: 1, justifyContent: "center", alignItems: "center" }}>
      <Text>Live Status: {isConnected ? "Online" : "Offline"}</Text>
      <Text>Type: {type}</Text>
      <Button title="Check Manually" onPress={checkManually} />
    </View>
  );
};

export default App;

Requirements

  • React Native >= 0.60.0
  • React >= 16.8.0 (for hooks)

Contributing

Contributions are welcome! Please submit a pull request or open an issue on GitHub.

License

MIT License. See LICENSE for details.

Acknowledgments

Built with by Parlegrandpa. Powered by @react-native-community/netinfo.