{"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.","language":"javascript","status":"active","last_verified":"Sun Apr 19","install":{"commands":["npm install react-native-contacts"],"cli":null},"imports":["import Contacts from 'react-native-contacts';","import type { Contact } from 'react-native-contacts';","import Contacts from 'react-native-contacts';\n// then use: Contacts.getAll()"],"auth":{"required":false,"env_vars":[]},"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()`.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}