🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more

react-native-keychain

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-native-keychain

Keychain Access for React Native

10.0.0
latest
Version published
Weekly downloads
193K
3.64%
Maintainers
1
Weekly downloads
 
Created

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

FAQs

Package last updated on 23 Mar 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts