Overhauling the Expo Updates API

Eric Samelson
Exposition
Published in
3 min readMar 30, 2018

--

One of the coolest features of an app built with Expo is the ability to deploy minor over-the-air (OTA) updates to your app after it’s published. Because Expo apps pull your Javascript bundles remotely from our servers, you can easily deploy new features and bugfixes straight to your users — meaning updates can be seamless and transparent.

In the past, we provided a workable but very limited API for developers to control OTA updates in their apps. Most behavior regarding updates differed across platforms, and limited custom configuration was available only in iOS standalone builds.

With SDK 26, we’ve overhauled much of this behavior, standardized it across iOS and Android, and provided a shiny new API to give developers way more control over their updates.

Automatic Updates

By default, Expo apps check for an updated bundle every time the app is launched. Previously, all Expo Android apps loaded updates in the background, while iOS apps defaulted to updating synchronously during launch. Starting in SDK 26, Expo developers can configure apps to automatically load updates synchronously (with a specific timeout) or asynchronously (with 0 timeout). This behavior will be respected across standalone/detached apps on both platforms, as well as the iOS and Android Expo Clients.

Synchronously updating on startup gives you a nice guarantee: your users will always be using the newest version of your app. But this comes at a cost: app startup time will be significantly slower on poor network connections and when downloading new updates.

For consumer apps, we strongly suggest setting updates.fallbackToCacheTimeout to 0 in app.json in order to always download updates in the background. This ensures the quickest possible launch for users, though sometimes requiring a second launch in order to run the latest version. For convenience, we’ve set this as the default in new project templates starting in SDK 26.

Manual Updates

If you’d rather your app not check for updates every time it’s launched, you can use the new Expo.Updates module to check if an update is available, fetch an update in the background while your app is running, and then load it when ready. (Read more in the Manual Updates section of our guide.)

This also allows you to wrap updating in custom logic — for example, you can prompt the user before loading an update, or choose to fetch updates only when the device is on a Wi-Fi connection.

No Updates

If you’d rather your standalone app never fetch remote updates, meaning all updates would need to go through the App Store or Play Store, you can now disable OTA updates in standalone or detached apps on both platforms.

More Info and Docs

For more detailed instructions about configuring the above workflows, refer to our Configuring OTA Updates guide.

See also the docs for updates configuration in app.json, and the Expo.Updates module.

The Future

We’ll be continuing to improve and iterate on this feature while trying to strike a balance between power and ease of use. If your use case isn’t covered here, or you have a great idea for extending this API, let us know by making a feature request or posting on our forums!

--

--