Skip to content

uiwjs/react-use-online

Repository files navigation

Using my app is also a way to support me:
Scap: Screenshot & Markup Edit Screen Test Deskmark Keyzer Vidwall Hub VidCrop Vidwall Mousio Hint Mousio Musicer Audioer FileSentinel FocusCursor Videoer KeyClicker DayBar Iconed Mousio Quick RSS Quick RSS Web Serve Copybook Generator DevTutor for SwiftUI RegexMate Time Passage Iconize Folder Textsound Saver Create Custom Symbols DevHub Resume Revise Palette Genius Symbol Scribe

React useOnline Hook

Buy me a coffee Follow On X 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

 
 
 

Contributors