{"id":13776938,"url":"https://github.com/pusherman/react-native-network-info","last_synced_at":"2025-05-11T10:31:28.963Z","repository":{"id":34920093,"uuid":"38974207","full_name":"pusherman/react-native-network-info","owner":"pusherman","description":"React Native library for getting information about the devices network","archived":false,"fork":false,"pushed_at":"2021-03-22T16:30:40.000Z","size":105,"stargazers_count":358,"open_issues_count":30,"forks_count":107,"subscribers_count":8,"default_branch":"master","last_synced_at":"2025-04-16T21:25:17.700Z","etag":null,"topics":["android","android-library","ios","ios-lib","network","networking","react-native"],"latest_commit_sha":null,"homepage":null,"language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pusherman.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-07-12T19:07:39.000Z","updated_at":"2024-12-26T06:14:41.000Z","dependencies_parsed_at":"2022-08-08T02:16:26.308Z","dependency_job_id":null,"html_url":"https://github.com/pusherman/react-native-network-info","commit_stats":null,"previous_names":[],"tags_count":19,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pusherman%2Freact-native-network-info","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pusherman%2Freact-native-network-info/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pusherman%2Freact-native-network-info/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pusherman%2Freact-native-network-info/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pusherman","download_url":"https://codeload.github.com/pusherman/react-native-network-info/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253551774,"owners_count":21926355,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["android","android-library","ios","ios-lib","network","networking","react-native"],"created_at":"2024-08-03T18:00:35.381Z","updated_at":"2025-05-11T10:31:25.779Z","avatar_url":"https://github.com/pusherman.png","language":"C","funding_links":[],"categories":["\u003ca name=\"Network:-Native-Modules\"\u003eNetwork: Native Modules\u003c/a\u003e"],"sub_categories":[],"readme":"# react-native-network-info\n\nReact Native library for getting information about the devices network\n\n## Requirements\n\nVersion 3+ requires RN 0.47 or higher\nVersion 2+ requires RN 0.40 - RN 0.46\n\n## Installation\n\n```javascript\nnpm install react-native-network-info --save\n```\n\nor\n\n```javascript\nyarn add react-native-network-info\n```\n\n### Linking the library\n\n#### Using React Native \u003e= 0.60\n\nLinking the package manually is not required anymore with Autolinking.\n\n#### `iOS` also requires CocoaPods install\n\n$ `cd ios \u0026\u0026 pod install \u0026\u0026 cd ..`\n\n#### Using React Native \u003c 0.60\n\n$ `react-native link react-native-network-info`\n\n## Usage\n\n```javascript\nimport {NetworkInfo} from 'react-native-network-info';\n\n// Get Local IP\nNetworkInfo.getIPAddress().then(ipAddress =\u003e {\n  console.log(ipAddress);\n});\n\n// Get IPv4 IP (priority: WiFi first, cellular second)\nNetworkInfo.getIPV4Address().then(ipv4Address =\u003e {\n  console.log(ipv4Address);\n});\n\n// Get Broadcast\nNetworkInfo.getBroadcast().then(broadcast =\u003e {\n  console.log(broadcast);\n});\n\n// Get SSID\nNetworkInfo.getSSID().then(ssid =\u003e {\n  console.log(ssid);\n});\n\n// Get BSSID\nNetworkInfo.getBSSID().then(bssid =\u003e {\n  console.log(bssid);\n});\n\n// Get Subnet\nNetworkInfo.getSubnet().then(subnet =\u003e {\n  console.log(subnet);\n});\n\n// Get Default Gateway IP\nNetworkInfo.getGatewayIPAddress().then(defaultGateway =\u003e {\n  console.log(defaultGateway);\n});\n\n// Get frequency (supported only for Android)\nNetworkInfo.getFrequency().then(frequency =\u003e {\n  console.log(frequency);\n});\n```\n\n### Manually Linking the Library\n\nIf `react-native link` fails and you are not using the auto linking provided in React Native \u003e= 0.60\n\n### `iOS`\n\n1. In XCode, in the project navigator, right click Libraries ➜ Add Files to [your project's name]\n\n2. Go to node_modules ➜ react-native-network-info and add the .xcodeproj file\n\n3. Add `RNNetworkInfo.a` to `Build Phases -\u003e Link Binary With Libraries`\n\nRun your project (Cmd+R)\n\n### `Android`\n\n1. Add the following lines to `android/settings.gradle`:\n\n   ```gradle\n   include ':react-native-network-info'\n   project(':react-native-network-info').projectDir = new File(settingsDir, '../node_modules/react-native-network-info/android')\n   ```\n\n2. Update the android build tools version to `2.2.+` in `android/build.gradle`:\n   ```gradle\n   buildscript {\n       ...\n       dependencies {\n           classpath 'com.android.tools.build:gradle:2.2.+' // \u003c- USE 2.2.+ version\n       }\n       ...\n   }\n   ...\n   ```\n3. Update the gradle version to `2.14.1` in `android/gradle/wrapper/gradle-wrapper.properties`:\n\n   ```\n   ...\n   distributionUrl=https\\://services.gradle.org/distributions/gradle-2.14.1-all.zip\n   ```\n\n4. Add the compile line to the dependencies in `android/app/build.gradle`:\n\n   ```gradle\n   dependencies {\n       ...\n       compile project(':react-native-network-info')\n   }\n   ```\n\n5. Add the import and link the package in `MainApplication.java`:\n\n   ```java\n   import com.pusherman.networkinfo.RNNetworkInfoPackage; // \u003c-- add this import\n\n   public class MainApplication extends Application implements ReactApplication {\n       @Override\n       protected List\u003cReactPackage\u003e getPackages() {\n           return Arrays.\u003cReactPackage\u003easList(\n               new MainReactPackage(),\n               new RNNetworkInfoPackage() // \u003c-- add this line\n           );\n       }\n   }\n   ```\n\n## Dev Notes\n\nNotes on how this package was made can be [found here](https://eastcodes.com/packaging-and-sharing-react-native-modules \"Packaging and Sharing React Native Modules\").\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpusherman%2Freact-native-network-info","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpusherman%2Freact-native-network-info","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpusherman%2Freact-native-network-info/lists"}