WhoBuilt

Self hosting mobile applications

Sep 14, 2018· 23 min· 789 views·Watch on YouTube

Speaker

Quinlan Jung, a software engineer at Expo, explains how to design and host over-the-air updates for React Native apps at a Callstack tech talk.

Build an update service from first principles

Jung uses a fictional game, Buggy Valley, to illustrate loading different JavaScript bundles in a React Native app. He explains that the native UI thread loads a bundle into memory through the bridge, where the JavaScript thread can run it.

Make updates smaller and faster

Jung turns the simple bundle-loading example into a service that downloads a new JavaScript bundle while keeping native modules unchanged. To avoid repeatedly downloading the same bundle, the app first checks a small `index.json` file, whose bundle URL uses an MD5-based name; it downloads the bundle only when that URL is not cached.

Choose when the app checks for updates

Expo users could publish through the DevTools GUI or by running `publish` in their project directory. Jung says the default was to check for updates at app startup, and that configurable update policies let teams change when to poll or opt out of updates.

Host bundles and assets yourself

Jung describes self-hosting as an option for teams facing high latency to Expo’s CDNs. Running `expo export` writes platform-specific `index.json` files, JavaScript bundles, and assets to disk; teams can host these files on GitHub or another server, then build a standalone iOS binary with a URL to the hosted index. For assets, the app checks local storage first, fetches missing files from the server, and caches them by hash.

Share the Snack announcement

Jung closes by announcing that Snack, a live coding environment for React Native similar to JSFiddle, is open source. He describes changing an app’s background color in the editor and seeing the change load on a phone.

Takeaways

  • Serve a small update manifest first, then download a JavaScript bundle only when its URL changes.
  • Keep JavaScript updates separate from native modules to avoid replacing the whole app binary for every change.
  • Let teams control update polling to fit their release and bandwidth needs.
  • For self-hosted updates, export platform bundles and assets, host them, and build the app with the manifest URL.
  • Cache assets by content hash so duplicate files can share storage and missing assets can be fetched on demand.

Mentioned in this talk

Search inside this talk

What was claimed 5

Related talks