A simple React Native hook to check if the device is connected to the internet.
- 🔌 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.
You can install the package using either npm or yarn:
npm install react-native-use-internet-status
yarn add react-native-use-internet-status
This package requires @react-native-community/netinfo.
If it’s not already installed in your project, install it as well:
npm install @react-native-community/netinfo
yarn add @react-native-community/netinfo
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;
This project is licensed under the MIT License – see the LICENSE for more details.