How to Implement OTA Updates in React Native: Auto-Restart with Expo

Marco Ceruti

Marco Ceruti

How to Implement OTA Updates in React Native: Auto-Restart with Expo

Keeping your mobile app up to date is critical for ensuring users experience the latest features and bug fixes. One of the easiest ways to handle this in React Native is by using over-the-air (OTA) updates with Expo. However, a common issue is that many users don’t restart their apps after an update, which prevents them from getting the latest version.

In this guide, we'll walk you through how to notify users when a new update is available and include a button that automatically restarts the app when clicked. This comprehensive guide is designed for developers who want to ensure their users receive the best experience without manual intervention.

What Are OTA Updates in React Native?

OTA updates allow you to push code changes to your users’ apps without requiring them to visit the app store. This method is especially useful for making small updates like bug fixes or minor feature additions.

In a React Native project, Expo offers built-in support for OTA updates. With Expo, you can push updates directly to users without publishing a new app version in the Play Store or App Store. These updates are applied the next time the user opens the app.

We already have an in-depth guid about "when and how to use OTA updates" if you want to know more about this topic.

Why Users Don’t Receive OTA Updates Automatically

Even though OTA updates are applied in the background, the app must be restarted for users to experience the new changes. Unfortunately, many users keep apps open for extended periods and may not manually restart them, leaving them on an outdated version.

To solve this problem, you can implement a pop-up notification to inform users of the update and provide a button that automatically restarts the app when clicked.

Key Technologies Used

Before we dive into the implementation, here are the core technologies and tools we’ll be using:

  • React Native: A JavaScript framework for building cross-platform mobile apps.

  • Expo: A platform for building React Native apps with native support and OTA updates.

  • expo-updates: An Expo library for managing updates in React Native apps.

Step-by-Step Implementation

1. Checking for Updates

To check for updates in a React Native app, you’ll use the expo-updates library. This allows you to programmatically determine whether a new update is available.

Start by installing expo-updates in your project:

expo install expo-updates

Then, you can check for updates using the following code snippet:

import * as Updates from 'expo-updates';

const checkForUpdates = async () => {
  try {
    const update = await Updates.checkForUpdateAsync();
    if (update.isAvailable) {
      await Updates.fetchUpdateAsync();
    }
  } catch (e) {
    console.error(e);
  }
};

This function checks whether a new update is available and, if so, fetches it. However, this won’t automatically restart the app — that’s what we’ll address next.

2. Displaying the Update Notification

You’ll need to notify users when an update is available. Using React Native’s Modal component, we can create a custom pop-up that informs users about the new update and provides a button to restart the app.

Here’s how you can set up a modal:

import React, { useState, useEffect } from 'react';
import { View, Text, Button, Modal } from 'react-native';
import * as Updates from 'expo-updates';

const UpdateModal = () => {
  const [modalVisible, setModalVisible] = useState(false);

  useEffect(() => {
    const checkForUpdates = async () => {
      try {
        const update = await Updates.checkForUpdateAsync();
        if (update.isAvailable) {
          setModalVisible(true);
        }
      } catch (e) {
        console.error(e);
      }
    };

    checkForUpdates();
  }, []);

  return (
    <Modal
      transparent={true}
      visible={modalVisible}
      animationType="slide"
    >
      <View style={{ flex: 1, justifyContent: 'center', alignItems: 'center' }}>
        <View style={{ padding: 20, backgroundColor: 'white', borderRadius: 10 }}>
          <Text>A new update is available. Restart to apply changes.</Text>
        </View>
      </View>
    </Modal>
  );
};

export default UpdateModal;

3. Adding a Restart Button

To make the update seamless, you can add a button that automatically restarts the app when clicked. Expo provides a function called Updates.reloadAsync() that restarts the app programmatically.

Here’s the updated modal component with the restart button:

const handleUpdate = async () => {
  try {
    await Updates.fetchUpdateAsync();
    await Updates.reloadAsync();  // This restarts the app
  } catch (e) {
    console.error(e);
  }
};

return (
  <Button title="Restart Now" onPress={handleUpdate} />
);

This will fetch the new update and restart the app, applying the changes immediately.

Configuring Update Settings in app.json

You can configure when and how your app checks for updates by modifying the app.json configuration file. Here's an example configuration:

{
  "expo": {
    "updates": {
      "enabled": true,
      "checkAutomatically": "ON_LOAD",
      "fallbackToCacheTimeout": 0
    }
  }
}
  • enabled: Enables OTA updates.

  • checkAutomatically: Ensures the app checks for updates whenever it is loaded.

  • fallbackToCacheTimeout: Ensures the app fetches the update immediately without falling back to cached versions.

For more details, check the official Expo Updates documentation.

Testing and Best Practices

Testing your OTA update mechanism across platforms is crucial:

  • iOS: Ensure the update is handled smoothly without forcing the user to restart immediately.

  • Android: Similarly, ensure the update process aligns with Android’s user experience guidelines.

Also, consider timing your updates to avoid pushing them during critical user workflows.

Frequently Asked Questions (FAQ)

Will this approach work for both iOS and Android?

Yes, Updates.reloadAsync() is supported on both platforms, ensuring consistent behavior across devices.

Can I control when the update is applied?

Yes, you can use Expo’s update configuration options in app.json to control when and how updates are fetched and applied.


This guide walks through everything from detecting OTA updates to restarting the app automatically, making the process seamless for your users. With these steps, your app will always stay up to date without relying on users to manually restart or update from the app store.