
Company News
Socket Named Top Sales Organization by RepVue
Socket won two 2026 Reppy Awards from RepVue, ranking in the top 5% of all sales orgs. AE Alexandra Lister shares what it's like to grow a sales career here.
react-native-connectivity-tracker
Advanced tools
Because we can no longer trust that react-native connectivity changes are valid, so we have to double check before we trust the result. Here's the RN issue
The only thing this library does is, whenever a network change event get's dispatched by NetInfo, we verify that the connection is alive by pinging google.
p.s: On production we verify by checking if our server is up (by overriding verifyServersAreUp) but you don't have to do that.
yarn install react-native-connectivity-tracker
Either follow the instructions in the React Native documentation to manually link the framework or link using Cocoapods by adding this to your Podfile:
pod 'react-native-netinfo', :path => '../node_modules/@react-native-community/netinfo'
Make the following changes:
android/settings.gradleinclude ':react-native-community-netinfo'
project(':react-native-community-netinfo').projectDir = new File(rootProject.projectDir, '../node_modules/@react-native-community/netinfo/android')
android/app/build.gradledependencies {
...
implementation project(':react-native-community-netinfo')
}
android/app/src/main/.../MainApplication.javaOn top, where imports are:
import com.reactnativecommunity.netinfo.NetInfoPackage;
Add the NetInfoPackage class to your list of exported packages.
@Override
protected List<ReactPackage> getPackages() {
return Arrays.asList(
new MainReactPackage(),
new NetInfoPackage()
);
}
import ConnectivityTracker from 'react-native-connectivity-tracker';
const onConnectivityChange = (isConnected, timestamp, connectionInfo) => {
console.log(`isConnected: ${isConnected}, when: ${timestamp} more info: ${JSON.stringify(connectionInfo)}`)
// connectionInfo is only available if attachConnectionInfo is set to true
}
ConnectivityTracker.init({
onConnectivityChange,
attachConnectionInfo: false,
onError: msg => console.log(msg),
// verifyServersAreUp: () => store.dispatch(checkOurServersAreUp()),
});
| Key | Type | Default | Definition |
|---|---|---|---|
| onConnectivityChange | function(bool, Date, Object) | - | This is the main callback you should care about. It get's dispatched whenever there's a connectivity change. |
| attachConnectionInfo | boolean | false | Attaches more details about the connection on the onConnectivityChange callback (3rd param) |
| alsoVerifyOnlineStatuses | boolean | false | By default we only verify the connectivity whenever we receive an offline status. By turning this on we'll also verify online statuses too. |
| dispatchOldEventsToo | boolean | false | By default we only dispatch the latest event we received from NetInfo. By turning this on we'll dispatch EVERYTHING. Caution, the order of events is not guaranteed if this is set to true. |
| onError | function | - | Pass a function here if you want to log errors. |
| verifyServersAreUp | function | - | This overrides the default verification method. Feel free to disregard this, unless want to use your own verification method, instead of relying to google responces. This function can return either a result (true or false) or a Promise |
| Key | Definition |
|---|---|
| tryConnection | This is a tottally optional method that you can call when you wish to check for a connectivity status on demand. Returnes a promise. |
FAQs
Checks wether the connection is valid
The npm package react-native-connectivity-tracker receives a total of 3 weekly downloads. As such, react-native-connectivity-tracker popularity was classified as not popular.
We found that react-native-connectivity-tracker demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Company News
Socket won two 2026 Reppy Awards from RepVue, ranking in the top 5% of all sales orgs. AE Alexandra Lister shares what it's like to grow a sales career here.

Security News
NIST will stop enriching most CVEs under a new risk-based model, narrowing the NVD's scope as vulnerability submissions continue to surge.

Company News
/Security News
Socket is an initial recipient of OpenAI's Cybersecurity Grant Program, which commits $10M in API credits to defenders securing open source software.