Storage engine for redux-persist
,
which can store sensitive data on the iOS/Android Keychain/Keystore,
by wrapping react-native-keychain
.
You should install react-native-keychain
alongside this library.
For now, v4 is recommended, as v5 on Android requires biometrics to access biometrics
(see oblador/react-native-keychain#316),
which doesn't allow for a seamless experience when rehydrating the store.
$ yarn add redux-persist-keychain-storage react-native-keychain@^4.0.5
The simplest way to use this library is in the default mode, where it stores the reducer data directly in the keychain.
There's a limit to the amount of data that can stored this way, so it's recommended to only use this with very minimal reducers, e.g. one that just stores key authentication data.
import { createKeychainStorage } from 'redux-persist-keychain-storage';
const keychainStorage = createKeychainStorage();
const persistConfig = {
// Keychain expects a reverse domain name qualifier (app bundle ID) style key
keyPrefix: 'com.myapp.persist.',
storage: keychainStorage,
};
const mainReducer = combineReducers({
token: persistReducer({ ...persistConfig, key: 'token' }),
});
To be implemented, API along lines of: import { createEncryptedStorage } from 'redux-persist-keychain-storage/crypt