Skip to main content

expo-secure-store

Version: 55.0.6 Provides a way to encrypt and securely store key-value pairs locally on the device. Uses Keychain on iOS and EncryptedSharedPreferences on Android to ensure data is stored securely.

Installation

Usage

API Reference

Methods

(key: string, value: string, options?: SecureStoreOptions) => Promise<void>
Stores a key-value pair securelyParameters:
  • key (string): Storage key
  • value (string): Value to store
  • options (SecureStoreOptions): Optional configuration
(key: string, options?: SecureStoreOptions) => Promise<string | null>
Retrieves a value by keyReturns null if key doesn’t exist
(key: string, options?: SecureStoreOptions) => Promise<void>
Deletes a stored value
() => Promise<boolean>
Checks if SecureStore is available on the platform

Types

SecureStoreOptions

string
iOS: Keychain service name. Android: SharedPreferences name
KeychainAccessibilityConstant
iOS: When the stored data is accessibleValues:
  • WHEN_UNLOCKED - Accessible when device is unlocked (default)
  • AFTER_FIRST_UNLOCK - Accessible after first unlock since boot
  • ALWAYS - Always accessible (deprecated)
  • WHEN_PASSCODE_SET_THIS_DEVICE_ONLY - Only when passcode is set
  • WHEN_UNLOCKED_THIS_DEVICE_ONLY - Device-only, when unlocked
boolean
iOS: Require Face ID/Touch ID to access
string
iOS: Prompt shown for biometric authentication

Constants

Examples

Basic Storage

Store Auth Token

Biometric Protection

Store JSON Data

Custom Keychain Service

Complete Auth Example

Platform Support

On iOS, SecureStore uses the system Keychain. On Android, it uses EncryptedSharedPreferences with AES-256 encryption.

Security Features

iOS (Keychain)

  • Hardware-backed encryption when available
  • Secure Enclave support
  • Face ID/Touch ID integration
  • Automatic iCloud Keychain sync (optional)
  • Data persists across app reinstalls (configurable)

Android (EncryptedSharedPreferences)

  • AES-256 encryption
  • Hardware-backed encryption on supported devices
  • Data removed on app uninstall

Best Practices

  1. Store Only Sensitive Data: Don’t use SecureStore for non-sensitive data (use AsyncStorage instead)
  2. Keep Values Small: Limit stored values to a few kilobytes
  3. Handle Errors: Always wrap operations in try/catch blocks
  4. Biometric Auth: Use requireAuthentication for highly sensitive data
  5. Clean Up: Delete sensitive data when no longer needed
  6. Check Availability: Use isAvailableAsync() before operations
SecureStore is not available on web. For cross-platform apps, implement a fallback storage mechanism or handle gracefully.

Common Use Cases

  • Auth tokens: Store JWT tokens or session IDs
  • API keys: Store API keys and secrets
  • User credentials: Store encrypted passwords (when necessary)
  • Payment info: Store sensitive payment tokens
  • Private keys: Store cryptographic keys

Limitations

  • Value size: Limited to a few kilobytes per entry
  • Not for large data: Use file system for large files
  • Web not supported: No secure storage equivalent in browsers
  • No synchronization: Data not automatically synced across devices

Resources