useOnline

React hook for checking if the user is online.

Installation

npm install @mvdlei/hooks

Usage

import React from "react";
import { useOnline } from "@mvdlei/hooks";
 
const App = () => {
  const isOnline = useOnline();
 
  return (
    <div>
      <h1>Is online: {isOnline ? "Yes" : "No"}</h1>
    </div>
  );
};

Reference

useOnline(): boolean;

use-online.ts