react-native-is-online
v0.1.0
Published
A React Native library to check DNS and network connectivity status seamlessly
Readme
react-native-is-online
A React Native library to check DNS and network connectivity status seamlessly
Installation
npm install react-native-is-onlineiOS
cd ios && pod installUsage
Get Report
import { IsOnline } from 'react-native-is-online';
// ...
const result = await IsOnline.getReport('https://google.com');Check Network with Timer
import { IsOnline } from 'react-native-is-online';
// ...
IsOnline.start('https://google.com', 60, (report) => {
console.log(`dns: ${report.checkDNS}`);
console.log(`statusCode: ${report.statusCode}`);
console.log(`connected: ${report.connected}`);
console.log(`errorCode: ${report?.errorCode}`);
...
});Report Type
export type Report = {
checkDNS: boolean; // Indicates if DNS resolution was successful
connected: boolean; // Indicates network connectivity status (return true when statusCode is 2xx or 3xx)
statusCode: number; // HTTP status code from connectivity check
errorCode?: number; // Optional error code if an error occurred
error?: string; // Optional error message if an error occurred
errorName?: string; // Optional error name or domain if an error occurred
};Contributing
License
MIT
Made with create-react-native-library
