Secure wallet key storage with Android BiometricPrompt + Keystore
npm install react-native-walletsecureSecurely store and retrieve cryptographic keys in the Android Keystore with biometric or device credential authentication.
Perfect for wallets, password managers, or any app that needs per-use biometric unlock for sensitive data.
---
---
``shAdd package
yarn add react-native-walletsecure
For local development:
`sh
yarn add file:../react-native-walletsecure
`---
β‘ Usage
`tsx
import React, { useState } from 'react';
import { View, Button, Text } from 'react-native';
import WalletSecure from 'react-native-walletsecure';export default function App() {
const [key, setKey] = useState(null);
const handleSave = async () => {
await WalletSecure.storeKey(
'my_wallet_key',
'super-secret-private-key',
{ title: 'Unlock to store', subtitle: 'Biometric required' },
true, // allow device credential fallback
);
};
const handleGetKey = async () => {
const value = await WalletSecure.retrieveKey(
'my_wallet_key',
{ title: 'Unlock to view key' },
true,
);
setKey(value);
};
return (
Stored Key: {key}
);
}
`---
π API Reference
$3
Store a string securely. - alias (string) β unique identifier for the key.
- value (string) β string to encrypt and save.
- promptConfig (object) β
{ title, subtitle } shown in biometric prompt.
- allowDeviceCredential (boolean) β allow PIN/pattern fallback. Default: true. ---
$3
Retrieve a previously stored value. - Shows biometric/device credential prompt before returning.
- Returns the decrypted string.
---
$3
Deletes a stored key by alias. ---
β οΈ Notes
- β
Only Android is supported right now. iOS support may come later.
- On Android, StrongBoxUnavailableException may occur if StrongBox isnβt available β the library auto-falls back to normal keystore.
- Minimum requirement: Android API 24+
- Biometric prompts may vary across manufacturers (Samsung, Pixel, etc.). ---
π§ͺ Development (Local Testing)
1. In your test app:
`sh
yarn add file:../react-native-walletsecure
`
2. Start Metro bundler with symlink support:
`sh
yarn start --reset-cache
`
3. Rebuild app after native changes:
`sh
cd android && ./gradlew clean && cd ..
yarn android
``---
---