What is react-native-keychain?
The react-native-keychain package provides a secure way to store and retrieve sensitive information such as passwords, tokens, and other credentials in a React Native application. It leverages the native keychain services on iOS and the Keystore system on Android to ensure data is stored securely.
What are react-native-keychain's main functionalities?
Storing Credentials
This feature allows you to securely store a username and password in the device's keychain or keystore.
import * as Keychain from 'react-native-keychain';
async function saveCredentials(username, password) {
await Keychain.setGenericPassword(username, password);
}
Retrieving Credentials
This feature allows you to retrieve stored credentials from the device's keychain or keystore.
import * as Keychain from 'react-native-keychain';
async function getCredentials() {
const credentials = await Keychain.getGenericPassword();
if (credentials) {
console.log('Credentials successfully loaded for user ' + credentials.username);
} else {
console.log('No credentials stored');
}
}
Resetting Credentials
This feature allows you to reset or delete the stored credentials from the device's keychain or keystore.
import * as Keychain from 'react-native-keychain';
async function resetCredentials() {
await Keychain.resetGenericPassword();
}
Storing Internet Credentials
This feature allows you to securely store internet credentials (e.g., server, username, password) in the device's keychain or keystore.
import * as Keychain from 'react-native-keychain';
async function saveInternetCredentials(server, username, password) {
await Keychain.setInternetCredentials(server, username, password);
}
Retrieving Internet Credentials
This feature allows you to retrieve stored internet credentials from the device's keychain or keystore.
import * as Keychain from 'react-native-keychain';
async function getInternetCredentials(server) {
const credentials = await Keychain.getInternetCredentials(server);
if (credentials) {
console.log('Internet credentials successfully loaded for server ' + server);
} else {
console.log('No internet credentials stored for server ' + server);
}
}
Other packages similar to react-native-keychain
react-native-sensitive-info
react-native-sensitive-info is another package that provides secure storage for sensitive information in React Native applications. It supports storing data in the Android Keystore and iOS Keychain, similar to react-native-keychain. However, it also offers additional features like encryption and the ability to store data in shared preferences or user defaults.
react-native-secure-storage
react-native-secure-storage is a package that provides secure storage for sensitive data in React Native applications. It uses the Android Keystore and iOS Keychain for secure storage, similar to react-native-keychain. It also supports encryption and offers a simple API for storing and retrieving data.
react-native-encrypted-storage
react-native-encrypted-storage is a package that provides secure and encrypted storage for sensitive data in React Native applications. It uses the Android Keystore and iOS Keychain for secure storage, similar to react-native-keychain. It also offers encryption and decryption of data, ensuring that sensitive information is stored securely.
react-native-keychain

This library provides access to the Keychain (iOS) and Keystore (Android) for securely storing credentials like passwords, tokens, or other sensitive information in React Native apps.
Installation
- Run
yarn add react-native-keychain
- Run
pod install
in ios/
directory to install iOS dependencies. - If you want to support FaceID, add a
NSFaceIDUsageDescription
entry in your Info.plist
. - Re-build your Android and iOS projects.
Documentation
Please refer to the documentation website on https://oblador.github.io/react-native-keychain
Changelog
Check the GitHub Releases page.
Maintainers
Used By
This library is used by several projects, including:
License
MIT © Joel Arvidsson 2016-2020