netinfo
Get network connection details of device in browser using navigator.connection API.
This package uses Expanded Network API and currently supported in latest version of chrome.
Installation
- NPM
npm install netinfo
- Yarn
yarn add netinfo
Usage
;// Other options ;)// let getNetInfo = require('netinfo');// <script src="./minified/index.js"></script> /** * Calling `getNetInfo()` returns current network connection details of device as object* {* downlink: 6.4,* downlinkMax: Infinity,* effectiveType: "4g",* rtt: 350,* type: "wifi"* }*/const currentNetInfo = ; // Optionally you can listen to net info changes// This callback will be called when there is change in net infolet { // Do something here};currentNetInfo;// Somewhere later in code, Remove net info change listener callbackcurrentNetInfo;
License
MIT © Ganapati V S