The async API
The async API returns Promises and is designed for asynchronous workflows:When to use async methods
Use async methods when:- Coordinating with other async operations - When storage operations are part of a larger async workflow
- You prefer Promise-based code - For consistency with other async APIs in your codebase
- Loading data in useEffect - When fetching data after component mount
- Network operations - When combining storage with API calls
The sync API
The sync API provides immediate access without Promises:When to use sync methods
Use sync methods for:- App initialization - Reading config or settings when the app starts
- Component initialization - Loading values during useState/useReducer setup
- Settings screens - Immediate reads and writes for user preferences
- Synchronous rendering logic - When you need values before the first render
Performance comparison
Sync methods are faster than async methods because they skip the Promise overhead:Android performance (1000 operations)
| Method Type | Time | Improvement |
|---|---|---|
| Sync | 98ms | Baseline |
| Async | 472ms | 4.8x slower |
iOS performance (1000 operations)
| Method Type | Time | Improvement |
|---|---|---|
| Sync | 1098ms | Baseline |
| Async | 1499ms | 1.4x slower |
The performance difference comes from Promise creation overhead, not the native storage operations themselves. Both APIs use the same native storage underneath.
iOS-specific considerations
On iOS, both async and sync methods useUserDefaults, which performs disk I/O synchronously (~1ms per write). For bulk write operations (1000+ writes), the disk I/O becomes the bottleneck:
ExpoNativeStorageModule.swift
UserDefaults.standard.set(), which writes to disk. The async wrapper doesn’t make the disk operation faster.
For typical use cases like app settings and user preferences, iOS sync methods provide excellent performance. For bulk operations (1000+ writes), consider specialized libraries like react-native-mmkv.
Android-specific considerations
On Android, both methods useSharedPreferences, which maintains an in-memory cache:
ExpoNativeStorageModule.kt
apply() method writes asynchronously to disk but updates the in-memory cache immediately, making subsequent reads instant from the cache.
Mixing async and sync
You can freely mix async and sync methods in the same app since they access the same storage:Best practices
Use sync for app initialization
Use sync for app initialization
Sync methods eliminate loading states and provide instant access to configuration:
Use async for network coordination
Use async for network coordination
When combining storage with API calls, async methods keep code consistent:
Use sync for immediate persistence
Use sync for immediate persistence
Settings screens benefit from immediate writes without Promise overhead:
Next steps
Platform Implementation
Learn how expo-native-storage works on each platform.
Best Practices
Discover patterns for error handling, type safety, and data management.