1.0.0 • Published 9 months ago

@uiw/react-use-online v1.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
9 months ago

React useOnline Hook

Build & Deploy Coverage Status NPM Version react@^18

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.