@uiw/react-use-online
v1.0.0
Published
useOnline is a tiny, zero-dependency hook for responding to online/offline changes.
Downloads
3,525
Readme
React useOnline Hook
useOnline
is a tiny, zero-dependency, SSR hook for responding to online/offline changes.
Quick Start
npm install @uiw/react-use-online
Using
You can use the Chrome Browser Debug Tool(f11) to set up offLine and onLine test hooks.
import React from "react";
import { useOnline } from '@uiw/react-use-online';
export default function App() {
const isOnline = useOnline();
return (
<div>
<h1 style={{ margin: 0 }}>useOnline</h1>
<div>{isOnline ? '✅ You are online' : '❌ You are offline'}</div>
</div>
);
}
Contributors
As always, thanks to our amazing contributors!
Made with contributors.
License
Licensed under the MIT License.