{"id":11764,"library":"react-native-contacts","title":"React Native Contacts","description":"React Native Contacts is a JavaScript library for React Native applications, providing cross-platform access to the device's contact list on both Android and iOS. The current stable version is 8.0.10. While not on a fixed release schedule, the library sees regular maintenance and bug fixes, with recent updates (like v8.0.0) focusing on compatibility with the new React Native architecture (TurboModules and Fabric). It also provides fixes for compatibility with older legacy bridge projects (v8.0.9, v8.0.10). Key differentiators include its long-standing support for both major mobile platforms, straightforward API for retrieving, adding, and updating contacts, and handling of native permissions. Users should be aware of performance considerations when using `getAll` and specific installation steps tailored for different React Native versions and architectures.","status":"active","version":"8.0.10","language":"javascript","source_language":"en","source_url":"https://github.com/morenoh149/react-native-contacts","tags":["javascript","react-native","react","react-component","addressbook","contacts","ios","android","typescript"],"install":[{"cmd":"npm install react-native-contacts","lang":"bash","label":"npm"},{"cmd":"yarn add react-native-contacts","lang":"bash","label":"yarn"},{"cmd":"pnpm add react-native-contacts","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Peer dependency for React Native application environment.","package":"react-native","optional":false},{"reason":"Peer dependency for React component model.","package":"react","optional":false}],"imports":[{"note":"Primarily designed for ESM. CommonJS `require` can lead to issues with newer React Native architectures or build systems.","wrong":"const Contacts = require('react-native-contacts');","symbol":"Contacts","correct":"import Contacts from 'react-native-contacts';"},{"note":"Type import for TypeScript users to define contact shape.","symbol":"Contact","correct":"import type { Contact } from 'react-native-contacts';"},{"note":"`getAll` is a method of the default `Contacts` object, not a named export. Attempting to destructure it directly will result in an undefined function.","wrong":"import { getAll } from 'react-native-contacts';","symbol":"{ getAll }","correct":"import Contacts from 'react-native-contacts';\n// then use: Contacts.getAll()"}],"quickstart":{"code":"import { PermissionsAndroid } from 'react-native';\nimport Contacts from 'react-native-contacts';\n\nconst fetchContacts = async () => {\n  try {\n    const granted = await PermissionsAndroid.request(\n      PermissionsAndroid.PERMISSIONS.READ_CONTACTS,\n      {\n        title: 'Contacts',\n        message: 'This app would like to view your contacts.',\n        buttonPositive: 'Please accept bare mortal',\n      }\n    );\n    if (granted === PermissionsAndroid.RESULTS.GRANTED) {\n      console.log('Contacts permission granted.');\n      const contacts = await Contacts.getAll();\n      console.log('Fetched contacts:', contacts.slice(0, 3)); // Log first 3 contacts\n      // Example: Access a specific contact's phone number\n      if (contacts.length > 0 && contacts[0].phoneNumbers && contacts[0].phoneNumbers.length > 0) {\n        console.log('First contact phone number:', contacts[0].phoneNumbers[0].number);\n      }\n    } else {\n      console.log('Contacts permission denied.');\n    }\n  } catch (err) {\n    console.error('Error fetching contacts:', err);\n  }\n};\n\nfetchContacts();","lang":"typescript","description":"This quickstart demonstrates how to request Android runtime permissions for contacts and then fetch all contacts using `Contacts.getAll()`."},"warnings":[{"fix":"Remove `pod 'react-native-contacts'` from your `ios/Podfile` if it exists. Run `npx react-native unlink react-native-contacts` if previously linked, then `npm install react-native-contacts` and `cd ios && pod install`.","message":"Starting with v7.0.0, manual linking (e.g., `react-native link`) and including a manual pod line in the `Podfile` for iOS projects are no longer needed due to autolinking support. Retaining the old pod line can cause build failures.","severity":"breaking","affected_versions":">=7.0.0"},{"fix":"For React Native 0.60+ (and especially with new architecture enabled), ensure `pod 'react-native-contacts', :path => '../node_modules/react-native-contacts'` is present in your `ios/Podfile` and run `pod install`. For Android, ensure `android/settings.gradle` and `android/app/build.gradle` are correctly configured for autolinking or manual linking if below RN 0.60.","message":"Version 8.0.0 introduced initial support for the new React Native architecture (TurboModules and Fabric). While aiming for backward compatibility, projects migrating to the new architecture or using React Native versions that leverage it should follow specific installation and linking steps.","severity":"breaking","affected_versions":">=8.0.0"},{"fix":"If using RN 0.60+, ensure your project has migrated to AndroidX. If using RN < 0.60, downgrade `react-native-contacts` to `4.x.x` (e.g., `npm install react-native-contacts@4`).","message":"For React Native versions 0.60 and above, AndroidX support is required. `react-native-contacts` versions 5.x+ include AndroidX support. If you are using React Native 0.59 or below, you must use `react-native-contacts` versions 4.x or older to avoid Android build conflicts.","severity":"breaking","affected_versions":">=5.0.0"},{"fix":"It is highly recommended to call `getAll()` before the data is critically needed and cache the results for subsequent uses. Consider implementing a loading state or background process for contact retrieval.","message":"The `Contacts.getAll()` method is a database-intensive process, and its execution time can be significant, especially with large contact lists. Calling it frequently or synchronously can degrade app performance.","severity":"gotcha","affected_versions":"*"},{"fix":"Add the `NSContactsUsageDescription` key and a user-facing message to your `Info.plist` file in Xcode.","message":"On iOS, you must add 'Privacy - Contacts Usage Description' (NSContactsUsageDescription) key to your `Info.plist` file with a descriptive string, otherwise your app will crash when attempting to access contacts.","severity":"gotcha","affected_versions":"*"}],"env_vars":null,"last_verified":"2026-04-19T00:00:00.000Z","next_check":"2026-07-18T00:00:00.000Z","problems":[{"fix":"Ensure `react-native-contacts` is properly linked for your React Native version and platform. For RN 0.60+, run `cd ios && pod install` after adding the pod line. For Android, verify `settings.gradle` and `app/build.gradle` configurations. Clean caches: `watchman watch-del-all && rm -rf node_modules && npm install && cd ios && pod install && cd .. && npm start -- --reset-cache`.","cause":"This error frequently indicates a linking issue where native modules are not correctly registered with the JavaScript bridge.","error":"Invariant Violation: Module AppRegistry is not a registered callable module (calling runApplication)"},{"fix":"Migrate your React Native project to AndroidX if using RN 0.60+. If you must use RN < 0.60, downgrade `react-native-contacts` to a `4.x.x` version by running `npm install react-native-contacts@4`.","cause":"This often occurs on Android when `react-native-contacts` versions 5.x+ are used with a React Native project that has not migrated to AndroidX (typically RN < 0.60).","error":"Execution failed for task ':app:processDebugMainManifest'. > Manifest merger failed with multiple errors, see logs."},{"fix":"For React Native 0.60+, ensure `pod 'react-native-contacts', :path => '../node_modules/react-native-contacts'` is added to your `ios/Podfile` inside your target, then run `cd ios && pod install`. For older RN versions, verify manual linking steps (dragging `RCTContacts.xcodeproj` to `Libraries` and linking `libRCTContacts.a` in Build Phases).","cause":"This iOS build error indicates that the `RCTContacts` native library could not be found, typically due to incorrect or missing linking.","error":"error: library not found for -lRCTContacts"}],"ecosystem":"npm"}