custom-expo-updates-server

repository·main·Indexed 19 days ago

https://github.com/expo/custom-expo-updates-server

A demonstration implementation of the Expo Updates protocol specification. It includes a reference server built with NextJS and a client app (expo-updates-client v1.0.0) to illustrate how to serve and consume over-the-air (OTA) updates using runtime versions, platforms, and manifests.

Tokens
651
Snippets
3
Records
6
Agent score
18%

What's inside custom-expo-updates-server

  1. How the Expo Updates flow works

    main

    The lifecycle of an update using this server follows these steps:

    1. Build Release App: Build a 'release' version of your app and run it on a simulator or device.
    2. Export Update: Make changes to your project and export them as an update.
    3. Deploy to Server: Copy the exported update to the server's updates/ directory, organized under a sub-directory corresponding to the runtime version.
    4. Request Manifest: The 'release' app requests an update. The server returns a manifest matching the app's platform and runtime version.
    5. Fetch Assets: The app requests each asset listed in the manifest from the server.
    6. Load Update: Once all assets are downloaded, the app loads the update.
  2. Understand Expo Updates terminology

    main

    To implement or use a custom updates server, you must understand these core concepts:

    • Runtime version (String): Specifies the version of the underlying native code. You must update the runtime version of an update whenever the native code changes (e.g., updating Expo SDK or adding native modules). If an update's runtime version does not match the app's native code, the app may crash.
    • Platform: Either "ios" or "android". Determines which platform-specific update to serve.
    • Manifest: An object (defined by the Expo Updates protocol) describing the assets and metadata an app needs to load an update.
  3. Export and publish an update

    main

    To push changes from the /expo-updates-client to the server:

    1. Navigate to /expo-updates-client and modify App.js.
    2. Navigate to the /expo-updates-server directory.
    3. Run the publish command. This script runs npx expo export in the client, then copies the exported app and the Expo config to the server's update directory.
    yarn expo-publish
  4. Configure the update server URL

    main

    By default, the client is configured to look for updates at http://localhost:3000. To use a different URL (e.g., for an Android emulator or remote server):

    1. Update .env.local in the custom-expo-updates-server directory.
    2. Update the updates.url key in the client's app.json.
    3. Re-run the build steps for the client app.
  5. Create a release version of the client app

    main

    The example client is located in /expo-updates-client. To create a release build for testing updates:

    iOS

    yarn
    yarn ios --configuration Release

    Android

    yarn
    yarn android --variant release
    yarn ios --configuration Release
    yarn android --variant release