React Native Secure Storage Configuration
Install and configure @tetherto/wdk-react-native-secure-storage
This page shows how to install @tetherto/wdk-react-native-secure-storage, create a storage instance, and configure authentication behavior.
Install the package
npm install @tetherto/wdk-react-native-secure-storage react-native-keychain expo-crypto expo-local-authenticationThe package declares react-native as a peer dependency and uses native modules through react-native-keychain.
Use this package in a React Native app or development build with native modules available. Expo Go is not enough for all keychain-backed flows.
Create a storage instance
Use createSecureStorage() once and reuse the returned object in your wallet storage layer.
import { createSecureStorage } from '@tetherto/wdk-react-native-secure-storage'
const storage = createSecureStorage({
authentication: {
promptMessage: 'Authenticate to access wallet',
cancelLabel: 'Cancel',
disableDeviceFallback: false
},
timeoutMs: 30000
})Store wallet material
Store encrypted values only. The package stores encrypted seed and entropy payloads plus the encryption key you provide.
const walletId = 'primary-wallet'
await storage.setEncryptedSeed(encryptedSeed, walletId)
await storage.setEncryptedEntropy(encryptedEntropy, walletId)
await storage.setEncryptionKey(encryptionKey, walletId, {
requireBiometrics: true
})Restore wallet material
Getters return null when a value has not been stored. They throw typed errors for validation, authentication, timeout, and keychain failures.
const walletId = 'primary-wallet'
const { encryptedSeed, encryptedEntropy, encryptionKey } =
await storage.getAllEncrypted(walletId)
if (!encryptedSeed || !encryptionKey) {
throw new Error('Wallet data is incomplete')
}Check device security
Use device checks before prompting the user to create or unlock a wallet.
const deviceSecurityEnabled = await storage.isDeviceSecurityEnabled()
const biometricsAvailable = await storage.isBiometricAvailable()
if (!deviceSecurityEnabled) {
throw new Error('Enable device security before creating a wallet')
}Cleanup
Call cleanup() when the storage instance is no longer needed. Use deleteWallet(identifier) when you want to remove stored wallet data.