Tuesday, March 27, 2018

Running Expo offline

Offline Expo:

I wanted to continue working on my expo project on my laptop while no wifi was present.   It was very hard to find information on how to do get it running, or if it was even possible.

Finally found the 2 magic commands!

This command will start the offline server.   No login required.
exp start --offline

This command will start the app in a running android emulator.
exp android --offline


To make this even easier (and so I didn't have to remember the commands) I just added them to my scripts in package.json

"scripts": {
"server": "exp start --offline",
"emulator": "exp android --offline"
}


Then I just run on one terminal:
npm run emulator


And in another terminal:
npm run server


Documentation:
To get the full offline experience, I also downloaded react-native, react-native-elements and expo from github so I can access the docs offline!   The gh-pages branch in react-native and react-native-elements contain the doc files, though the links won't work, so you have to browse to them manually.   Still better than no docs at all!

4 comments:

  1. hi, what package you use for offline save-load redux state?

    ReplyDelete
  2. I use AsyncStorage. I JSON.stringify the part of state I want to save and put it into an AsyncStorage key. On load I read that key and then rehydrate my redux state from it.

    ReplyDelete
  3. I'd also recommend Dash (https://kapeli.com/dash) for offline docs

    ReplyDelete
  4. I have now switched to jotai for app state. It also provides a way for RN to save the state automatically to AsyncStorage. Took out a ton of boilerplate code that way!

    ReplyDelete