# Introduction

This version supports TypeScript

## **Installation**

Install the package using npm or yarn

```bash
npm install re-use-online
```

or

```bash
yarn add re-use-online
```

### Usage

Import the `useOnlineStatus` hook into your React component and use it to check the online status.

```javascript
import React from "react";
import useOnlineStatus from "re-use-online";

function MyComponent() {
  const isOnline = useOnlineStatus();

  return (
    <div>
      {isOnline ? (
        <p>You are connected to the internet!</p>
      ) : (
        <p>No Internet Connection</p>
      )}
    </div>
  );
}

export default MyComponent;
```

### How it works

The `useOnlineStatus` hook utilizes the `navigator.onLine` property to determine the initial online status of the user's device. It also adds event listeners for the `online` and `offline` events to update the online status dynamically.

### License

This project is licensed under the MIT License - see the [LICENSE](https://github.com/Akarikev/is-online-status/blob/master/LICENSE) file for details.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://princes-organization-3.gitbook.io/reuseonline-docs/readme.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
