@uiw/react-use-online
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published

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.

Package Sidebar

Install

npm i @uiw/react-use-online

Weekly Downloads

9

Version

1.0.0

License

MIT

Unpacked Size

4.26 kB

Total Files

7

Last publish

Collaborators

  • uiwjs
  • wcjiang