online-status-react
v1.2.0
Published
A simple React hook to detect online/offline status
Downloads
20
Maintainers
Readme
online-status-react
A simple and lightweight React custom package to detect if the user is online or offline using the browser's native online/offline events.
🚀 Installation
npm install online-status-react
yarn add online-status-react
📦 Quick Example
import React from "react";
import { useOnline } from "online-status-react";
function App() {
const isOnline = useOnline();
return (
<div
style={{
fontFamily: "sans-serif",
textAlign: "center",
marginTop: "50px",
}}
>
<h1>Internet Status Checker</h1>
<p style={{ fontSize: "20px" }}>
{isOnline ? "✅ You are Online" : "❌ You are Offline"}
</p>
</div>
);
}
export default App;