Skip to content

HamidAliSE/react-native-use-internet-status

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

react-native-use-internet-status

A simple React Native hook to check if the device is connected to the internet.

Features

  • 🔌 Simple hook to check internet connectivity in React Native.
  • ⚡ Lightweight and built on top of @react-native-community/netinfo.
  • 🛠️ Easy to integrate in any project – just import and use.

Installation

You can install the package using either npm or yarn:

With npm

npm install react-native-use-internet-status

With yarn

yarn add react-native-use-internet-status

Peer dependency

This package requires @react-native-community/netinfo. If it’s not already installed in your project, install it as well:

With npm

npm install @react-native-community/netinfo

With yarn

yarn add @react-native-community/netinfo

Usage

Import the hook and use it in your component to track internet connectivity:

import { Text, View } from 'react-native';
import useInternetStatus from 'react-native-use-internet-status';

const App = () => {
    const { isConnected } = useInternetStatus();

    if (isConnected === null) {
        return <Text>Checking connection...</Text>;
    }

    return (
        <View>
            {isConnected ? (
                <Text>You are Online ✅</Text>
            ) : (
                <Text>No Internet Connection ❌</Text>
            )}
        </View>
    );
};

export default App;

License

This project is licensed under the MIT License – see the LICENSE for more details.

About

A simple React Native hook to check if the device is connected to the internet.

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors