Your app will encounter circumstances where the internet connection is sub-par or totally unavailable and it still needs to work reasonably well. This guide offers more information and best practices for providing a great experience while the device is offline.
When you publish
an update to your app, your users will receive the new version of your JS over the air. The new version will download either next time the app starts, or next time you call Updates.reload()
. This behavior also applies the very first time the user opens your app.
Expo offers multiple behaviors for how it should download your JS. It can either block the UI with a splash screen
or AppLoading component
until the new JS is downloaded, or it can immediately show an old version of your JS and download the update in the background. The former option is better if your users must have the latest version at all times; the latter option is better if you have a bad internet connection and need to show something right away.
To force JS updates to run in the background (rather than synchronously checking and downloading on app start), set
. You can also listen to see when a new version has finished downloading. For more information, see Configuring OTA Updates
By default, all of your assets (images, fonts, etc.) are uploaded to Expo's CDN
when you publish updates to your app, which allows you to update them over the air. Once they're downloaded, you can cache them
so you don't need to download them a second time. If you publish changes, the cache will be invalidated and the changed version will be downloaded.
Expo can bundle assets into your standalone binary during the build process so that they will be available immediately, even if the user has never run your app before. This is important if:
- Your users may not have internet the first time they open your app, or
- If your app relies on a nontrivial amount of assets for the very first screen to function properly.
To bundle assets in your binary, use the assetBundlePatterns
to provide a list of paths in your project directory:
Images with paths matching the given patterns will be bundled into your native binaries next time you run
In the bare workflow, Xcode and Android Studio don't automatically run
expo publish as part of the build process, so the
assetBundlePatterns key doesn't apply in this case. Instead, any assets that are explicitly
require()'d anywhere in your codebase (including in your dependencies) are bundled into your binary. This is the same behavior as with regular React Native apps.
React Native exposes the NetInfo
API, which informs you if your device's reachability changes. You may want to change your UI (e.g. show a banner, or disable some functions) if you notice that there's no connection available.