Common errors
Error: Cannot find native module 'ExpoNativeStorage'
Error: Cannot find native module 'ExpoNativeStorage'
This error means the native module isn’t linked properly. This is the most common issue when first installing expo-native-storage.The 3. Verify you’re not using Expo Goexpo-native-storage requires native code and does not work with Expo Go. You must use a development build:4. Verify the package is installedCheck that expo-native-storage is in your If it’s missing, install it:
Solutions
1. Rebuild your app after installationThe native module requires a rebuild to link properly:--clean flag removes existing native directories before generating new ones.2. Clear all cachesIf rebuilding doesn’t work, clear all caches:package.json:package.json
iOS: Module not found in Podfile.lock
iOS: Module not found in Podfile.lock
If the module isn’t linking on iOS, verify it appears in the Podfile.If it’s missing, reinstall pods:2. Clean build folderClean the iOS build folder and rebuild:3. Prebuild from scratchRemove the iOS directory and prebuild:
Solutions
1. Check Podfile.lockVerify the module is in yourios/Podfile.lock:Android: Module not found in build.gradle
Android: Module not found in build.gradle
If the module isn’t linking on Android, verify the gradle configuration.2. Clean gradle cacheClean the gradle cache and rebuild:3. Prebuild from scratchRemove the Android directory and prebuild:
Solutions
1. Check gradle dependenciesVerify the module is in your Android dependencies:TypeError: Cannot read property 'setItem' of undefined
TypeError: Cannot read property 'setItem' of undefined
This error occurs when trying to use Storage before it’s properly imported.
Solution
Verify you’re importing Storage correctly:Web: QuotaExceededError
Web: QuotaExceededError
This error occurs when localStorage exceeds the browser’s storage quota (typically 5-10MB).2. Handle quota errors gracefullyCatch and handle quota errors:3. Clear old data periodicallyImplement a cleanup strategy:
Solutions
1. Reduce data sizeStore less data or split large objects into smaller chunks:Data not persisting between app restarts
Data not persisting between app restarts
If data isn’t persisting, verify you’re calling the storage methods correctly.2. Use sync methods for critical dataSync methods ensure immediate persistence:3. Verify you’re using the correct keysCheck for typos in key names:
Solutions
1. Verify writes completeEnsure async writes complete before the app closes:iOS: Data cleared after app update
iOS: Data cleared after app update
UserDefaults data persists between app updates by default. If data is being cleared, check your implementation.2. Check app uninstall/reinstallData is cleared when the app is uninstalled. This is expected behavior.3. Verify bundle identifier hasn’t changedChanging your app’s bundle ID creates a new storage domain, losing previous data.
Solutions
1. Don’t call clear() unnecessarilyAndroid: Data cleared after app update
Android: Data cleared after app update
SharedPreferences data persists between app updates. If data is being cleared, verify your implementation.3. Check package name hasn’t changedChanging your package name creates new storage, losing previous data.
Solutions
1. Check storage permissionsVerify your app has storage permissions inAndroidManifest.xml. expo-native-storage doesn’t require special permissions, but some devices may behave differently.2. Don’t call clear() unnecessarilyVerification steps
Follow these steps to verify expo-native-storage is working correctly:Verify native linking (iOS)
Check that the module appears in your Podfile.lock:If this returns results, the module is linked on iOS.
Verify native linking (Android)
Check gradle dependencies:If this returns results, the module is linked on Android.
Getting help
If you’re still experiencing issues after trying these solutions:- Check the GitHub issues - Search for similar issues: expo-native-storage/issues
-
Create a new issue with:
- Your Expo SDK version (
expo --version) - React Native version (from
package.json) - Platform (iOS/Android/Web)
- Full error message and stack trace
- Whether you’re using Expo Go or a development build
- Steps to reproduce the issue
- Your Expo SDK version (
-
Verify requirements:
- Expo SDK 50+ required
- Development builds required (not Expo Go)
- Native code must be linked via
expo prebuild
Next steps
Installation Guide
Review the installation steps to ensure proper setup.
Best Practices
Learn patterns for effective storage usage.