A React Native library to check DNS and network connectivity status seamlessly
npm install react-native-is-onlinecd ios && pod installimport { IsOnline } from 'react-native-is-online';
// ...
const result = await IsOnline.getReport('https://google.com');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}`);
...
});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
};MIT
Made with create-react-native-library