Skip to main content
Version: v11.15.4

Storage Service

Storage Services handle local data storage in React Native apps. Use StorageService for general app data and SecureStorageService for sensitive data.

SecureStorage​

StorageService is built on top of @react-native-async-storage/async-storage and is recommended for storing general, non-sensitive data such as user preferences, app flags, or cached information.

Usage Example​

App.getDependency('StorageService').setItem("superHero", "Batman");

Supported Methods​

MethodDescription
getItem(key)Retrieves the value for the given key. Returns a Promise<string or null>.
setItem(key, value)Stores the value under the given key. Returns a Promise<void>.
removeItem(key)Removes the value for the given key. Returns a Promise<void>.
getAll()Retrieves all stored key-value pairs as an object. Returns a Promise<object>.

SecureStorageService​

SecureStorageService is intended for sensitive information like authentication tokens, passwords, or API keys. It uses expo-secure-store (or platform-specific secure storage solutions) to store data securely.

note

SecureStorageService supports a maximum of 4KB per key. It is not recommended for large datasets.

Usage Example​

App.getDependency('SecureStorageService').setItem("superHero", "Bruce wayne");

Supported Methods​

MethodDescription
getItem(key)Retrieves a securely stored value for the given key.
setItem(key, value)Stores the value securely under the given key.
removeItem(key)Removes a securely stored value.
note

Unlike StorageService, getAll() is not available in SecureStorageService.

For detailed implementation guides and examples, see Secure Store Implementation Guide.

Choosing the Right Service​

Use CaseRecommended Service
General app data, UI flags, cached responsesStorageService
Tokens, passwords, secrets, and sensitive user dataSecureStorageService