Is it possible to retrieve AsyncStorage data when migrating from vanilla RN to Expo?


I’m trying to do the opposite of eject, i.e. move from a vanilla React Native app to a managed Expo app.

  1. Is there a guide for how to do this in general?
  2. In particular, is there a way to retrieve local user data that was previously stored in AsyncStorage in users’ devices?

For example:

Start off with a bare React Native app and run the following:

  • AsyncStorage.setItem('foo', 'bar')
  • await AsyncStorage.getItem('foo') // output is bar, as expected

Convert the app to a managed Expo app (same bundleIdentifier / package) and run the following

  • await AsyncStorage.getItem('foo') // empty

i.e. whatever data was saved to AsyncStorage in vanilla RN is no longer accessible when I migrate to Expo.

It seems like Expo’s AsyncStorage is fetching from ${FileSystem.documentDirectory}/RCTAsyncLocalStorage/manifest.json, and FileSystem.documentDirectory is something along the lines of Documents/ExponentExperienceData/some-function-of-expo-user-and-slug, i.e. a new directory. I imagine there’s a way to migrate the data from the “normal” AsyncStorage dir that was used by vanilla RN to here.

Any updates? I guess it doesn’t have to be AsyncStorage in particular (can migrate data to expo-secure-store or expo-sqlite) – generally just wondering what would be the recommended approach if I want to migrate from a bare RN app to a managed Expo app while being able to recover local data on users’ devices.

The tricky bit … and I’m in the middle of it in another venue … is breaching the high walls between apps in the mobile world. Writing and reading the local space is easy, but writing and reading a space that a subsequent app can read is … challenging.

The simplest thing, assuming you have enough data to be worth the trouble, is to dump it out (it will be stringified JSON), put it somewhere on the web, then – in the new app – read it back. I haven’t tried this yet, but the expo FileSystem API has, for example, a remote read, or you can use Axios or any similar library.

What I’d really like to see is some kind of better implementation of Sharing, or some implementation of a shared file space that can be accessed by more than one app. I hear sharing is on the drawing board but no time soon.

Anybody else have a better idea than reading from an external URL?

if you build your app with EAS Build we will read AsyncStorage data from the same place, because we just use the exact same code from the AsyncStorage library. i’d recommend using EAS Build instead of the “classic” build system - it’s much more flexible and results in smaller binaries.