[go: up one dir, main page]

Skip to content

useOnline is a tiny, zero-dependency hook for responding to online/offline changes.

License

Notifications You must be signed in to change notification settings

uiwjs/react-use-online

Repository files navigation

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>
  );
}

Related

  • useColorScheme useColorScheme() is a tiny, zero-dependency, SSR hook for responding to devices color scheme changes.

Contributors

As always, thanks to our amazing contributors!

Made with contributors.

License

Licensed under the MIT License.

About

useOnline is a tiny, zero-dependency hook for responding to online/offline changes.

Resources

License

Stars

Watchers

Forks

Sponsor this project

Packages

No packages published