{"library":"react-native-keychain","title":"React Native Keychain Access","description":"react-native-keychain is a library providing secure access to platform-native credential storage on iOS (Keychain) and Android (Keystore). It enables React Native applications to securely store sensitive data such as passwords, authentication tokens, and other user credentials, protecting them from unauthorized access. The current stable version is 10.0.0, released in late 2024 / early 2025. The project has a consistent release cadence with multiple patch and minor versions preceding major updates, indicating active maintenance and feature development. Key differentiators include robust support for biometric authentication, integration with Android's Jetpack DataStore for enhanced security and performance, and optional iCloud synchronization for iOS keychain items. It explicitly supports modern React Native versions and provides TypeScript definitions.","language":"javascript","status":"active","last_verified":"Sun Apr 19","install":{"commands":["npm install react-native-keychain"],"cli":null},"imports":["import * as Keychain from 'react-native-keychain';","import { getGenericPassword } from 'react-native-keychain';","import { ACCESSIBLE, SECURITY_LEVEL } from 'react-native-keychain';"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import * as Keychain from 'react-native-keychain';\n\nasync function storeAndRetrieveCredentials(username: string, password_input: string) {\n  try {\n    // Store the credentials\n    await Keychain.setGenericPassword(username, password_input, {\n      service: 'myAppService',\n      accessControl: Keychain.ACCESSIBLE.WHEN_UNLOCKED_THIS_DEVICE_ONLY,\n      securityLevel: Keychain.SECURITY_LEVEL.SECURE_SOFTWARE\n    });\n    console.log('Credentials successfully stored!');\n\n    // Retrieve the credentials\n    const credentials = await Keychain.getGenericPassword({\n      service: 'myAppService'\n    });\n\n    if (credentials) {\n      console.log('Credentials successfully loaded for user ' + credentials.username);\n      console.log('Password is ' + credentials.password);\n      // In a real app, you would use these credentials, not log the password directly.\n    } else {\n      console.log('No credentials stored.');\n    }\n\n    // Example of resetting credentials\n    await Keychain.resetGenericPassword({ service: 'myAppService' });\n    console.log('Credentials successfully reset!');\n\n  } catch (error) {\n    console.error('Keychain operation failed', error);\n  }\n}\n\n// Example usage:\n// Use environment variables or secure inputs in a real application\nconst myUsername = process.env.KEYCHAIN_USERNAME ?? 'testuser';\nconst myPassword = process.env.KEYCHAIN_PASSWORD ?? 'supersecretpassword';\n\nstoreAndRetrieveCredentials(myUsername, myPassword);","lang":"typescript","description":"Demonstrates how to store, retrieve, and reset generic credentials (username/password) using `react-native-keychain` with specific access control and security levels.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}