use-network-state3
TypeScript icon, indicating that this package has built-in type declarations

1.0.1 • Public • Published

use-network-state3

Monitor and adapt to network conditions seamlessly with useNetworkState.

Installation

To install the package, use npm:

pnpm add use-network-state3

yarn install use-network-state3

npm install use-network-state3

Usage

import React from "react";
import { useNetworkState } from "use-network-state3";

const NetworkStatus = () => {
  const networkState = useNetworkState();

  return (
    <div>
      <p>Online: {networkState.online ? "Yes" : "No"}</p>
      {networkState.since && (
        <p>Since: {networkState.since.toLocaleTimeString()}</p>
      )}
      {networkState.downlink && <p>Downlink: {networkState.downlink} Mb/s</p>}
      {networkState.effectiveType && (
        <p>Effective Connection Type: {networkState.effectiveType}</p>
      )}
      {networkState.type && <p>Connection Type: {networkState.type}</p>}
      <p>Data Saver Mode: {networkState.saveData ? "Enabled" : "Disabled"}</p>
    </div>
  );
};

export default NetworkStatus;

tsup

Bundle your TypeScript library with no config, powered by esbuild.

https://tsup.egoist.dev/

How to use this

  1. install dependencies
# pnpm
$ pnpm install

# yarn
$ yarn install

# npm
$ npm install
  1. Add your code to src
  2. Add export statement to src/index.ts
  3. Test build command to build src. Once the command works properly, you will see dist folder.
# pnpm
$ pnpm run build

# yarn
$ yarn run build

# npm
$ npm run build
  1. Publish your package
$ npm publish

test package

https://www.npmjs.com/package/use-network-state3

Readme

Keywords

none

Package Sidebar

Install

npm i use-network-state3

Weekly Downloads

1

Version

1.0.1

License

MIT

Unpacked Size

259 kB

Total Files

19

Last publish

Collaborators

  • dimetrix