Skip to content

React Native Secured Storage - Stores encrypted data to AsyncStorage

Notifications You must be signed in to change notification settings

SolidStateGroup/react-native-secured-storage

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

React Native Secured Storage

Getting Started

Install

yarn add react-native-secured-storage react-native-keychain https://github.com/SolidStateGroup/react-native-pbkdf2 @react-native-community/async-storage

or

npm install --save react-native-secured-storage react-native-keychain https://github.com/SolidStateGroup/react-native-pbkdf2 @react-native-community/async-storage

Link

  • React Native 0.60+

CLI autolink feature links the module while building the app.

  • React Native <= 0.59
$ react-native link react-native-keychain react-native-pbkdf2 @react-native-community/async-storage

Note For iOS using cocoapods, run:

$ cd ios/ && pod install

See docs for manual linking guide

Upgrading to React Native 0.60+

New React Native comes with autolinking feature, which automatically links Native Modules in your project. In order to get it to work, make sure you unlink dependencies first first:

$ react-native unlink react-native-keychain react-native-pbkdf2 @react-native-community/async-storage

Usage

Import

import SecuredStorage from 'react-native-secured-storage';

Initialise

await SecuredStorage.init('mypassword');

Unlock storage / Get data

get() would be called once on relaunching the app if secured storage has already been initialised.

const storage = await SecuredStorage.get();
const mydata = storage['mydata'];
const mydata2 = SecuredStorage.storage['mydata2'];

Store data

await SecuredStorage.setItem('key', {complex: 'object'});
await SecuredStorage.setItem('key', null, 'or just a string');

Remove data

await SecuredStorage.removeItem('key');

About

React Native Secured Storage - Stores encrypted data to AsyncStorage

Resources

Stars

Watchers

Forks

Packages

No packages published