Skip to main content

How to force update a React Native app

Sooner or later every React Native app needs to make sure people stop using an old version: you changed your API, fixed a security issue, or a release crashes on launch. The App Store and Google Play don't do this for you, so the app itself has to check whether its version is still allowed and, if not, ask the user to update.

This guide shows how to do that with Appcockpit: you set the rules in a dashboard, and the React Native SDK shows a forced or optional update prompt when the app starts. Changing the rules later doesn't need a new release.

In short:

  1. Install appcockpit-react-native-sdk and wrap your app in AppUpdateProvider.
  2. In the Appcockpit dashboard, set a minimum version (for example 2.0.0) and turn on Force Update.
  3. Everyone on a lower version gets a full-screen prompt that sends them to the App Store or Google Play and can't be dismissed.

Force update or optional update?​

Forced update screen in a React Native app: Update Required, with only an Update now button
Forced update: only "Update now"
Optional update screen in a React Native app: Update Available, with Update now and Later buttons
Optional update: "Update now" or "Later"
Forced updateOptional update
User can dismiss itNoYes, and a dismissed version isn't shown again
Use it forBreaking API changes, security fixes, broken releasesNew features, nudging people to upgrade
RiskBlocks people until they updatePeople can stay on old versions

A good default is an optional prompt for the previous release and a forced update only for versions you really can't support anymore.

How the check works​

Flowchart: the app starts, the SDK checks with Appcockpit, then shows a rule's prompt for an exact version, an update prompt below the minimum version, or no prompt

There are two kinds of rules:

  • Minimum version: everyone below a version is asked to update, for example everything below 2.0.0. This is what you want in most cases. Users exactly on the minimum version are not prompted.
  • Version rule: a rule for one exact version, for example a release that crashes. It takes priority over the minimum version.

Both are set per platform (iOS or Android) and per environment (for example production and staging), and each one is either forced or optional.

The do-it-yourself options​

You can build this yourself, and it's worth knowing the trade-offs:

  • Compare against the store version (for example with a library that reads the current App Store or Play Store version). Simple, but it can only say "a newer version exists". You can't force only some versions, and it breaks when store pages change.
  • Firebase Remote Config plus your own UI. Store a minimum version in Remote Config and compare it in the app. Flexible, but you build and maintain the version comparison, the update screens for both platforms, the store links and the "dismissed" state yourself.
  • Your own backend endpoint. Full control, and the most work: an API, an admin screen to change the minimum version, and the same app-side work as above.
  • Google Play In-App Updates. Android only; there's no equivalent on iOS.

Appcockpit does the checking, the rules, the dashboard and the update UI for both platforms, so the integration is a few lines.

Step 1: Create your app in Appcockpit​

  1. Create an account (there's a 30-day free trial, no credit card required) and create an app. See Getting started.
  2. Open the app's Settings tab and copy the App ID and the API Token.

Your app gets a production environment. Add a staging environment if you want to test rules on internal builds first.

Step 2: Install the SDK​

npm install appcockpit-react-native-sdk @react-native-async-storage/async-storage

@react-native-async-storage/async-storage is a peer dependency; the SDK uses it to remember dismissed optional updates. The SDK itself has no native code, so it also works in Expo apps.

Step 3: Wrap your app​

The SDK needs your app's current version. Read it from the native app instead of hard-coding it, for example with react-native-device-info:

App.tsx
import { Platform } from "react-native";
import DeviceInfo from "react-native-device-info";
import { AppUpdateProvider, type AppInfo } from "appcockpit-react-native-sdk";

const appInfo: AppInfo = {
platform: Platform.OS === "ios" ? "ios" : "android",
appId: "<appcockpit_app_id>",
// iOS: the numeric App Store ID. Android: the package name.
appstoreId: Platform.OS === "ios" ? "1234567890" : "com.example.myapp",
appVersion: DeviceInfo.getVersion(), // e.g. "1.9.4"
environment: "production",
};

export default function App() {
return (
<AppUpdateProvider info={appInfo} apiToken="<api_token>">
<RootNavigator />
</AppUpdateProvider>
);
}

In Expo, use Application.nativeApplicationVersion from expo-application instead of DeviceInfo.getVersion().

If your app has logged-in users, also pass userId. Appcockpit then counts each user once at their latest version, which makes Version adoption in the dashboard much more precise (see step 4).

That's the whole integration. On every start, AppUpdateProvider checks the version and shows the prompt when a rule applies. Update now opens your app's page in the App Store or Google Play.

tip

Use a separate environment for development and TestFlight builds, for example environment: __DEV__ ? "staging" : "production". Then you can try rules in staging without affecting real users.

Step 4: Set a minimum version​

In the dashboard, open your app and go to Versions → Minimum Versions → Add Requirement:

  1. Choose the platform (iOS or Android) and the environment.
  2. Enter the minimum version, for example 2.0.0.
  3. Turn on Force Update if users must update. Leave it off for a dismissible prompt.
  4. Optionally add a message, then click Create Minimum Version.

Users below 2.0.0 see the update prompt the next time they open the app. Before you create it, check how many users it would affect: the app's Dashboard shows it under Version adoption → What if you set a minimum version?

What-if calculator in the Appcockpit dashboard: a minimum of 2.0.0 on iOS would ask 840 tracked users (33.9%) to update

To block one specific release instead, add a version rule under Versions → Add Version with that exact version and Force Update Required turned on.

Step 5: Test it​

At the bottom of the Versions tab, Test a version shows what a user on a given version gets right now, without changing anything:

Test a version in the Appcockpit dashboard: iOS 1.9.4 in production gets a forced update because the minimum version is 2.0.0

To see it on a device, set a minimum version in staging that's higher than your build's version and start the app.

Customize the update prompt​

  • Your own UI: pass a component as UpdateScreen to AppUpdateProvider. It gets onUpdate and, for optional updates, onClose. See Custom update version UI.

  • Native alert instead of a full screen: call checkVersionUpdate(appInfo, apiToken) yourself, for example after login.

    Native iOS alert: Update Required, A critical update is required
  • Messages and languages: add a message to the rule in the dashboard, plus translations per language. The built-in screens come in 20 languages; pass languageKey (for example LanguageKey.DE) to choose one.

  • Button colors: pass theme={{ updateButton: { backgroundColor, textColor } }}.

Bonus: maintenance mode​

The same SDK can show a full-screen maintenance message, for example during a database migration, without an app update. Wrap your app in MaintenanceProvider as well and switch it on in the dashboard. See Maintenance.

FAQ​

How do I force users to update a React Native app?​

Add a check on app start that compares the installed version with a minimum version you control, and show a non-dismissible screen that links to the App Store or Google Play when the version is too old. With Appcockpit, wrap the app in AppUpdateProvider and set a forced minimum version in the dashboard.

Do I need to release a new version to change the minimum version?​

No. The app asks Appcockpit on every start, so a new minimum version or a change from optional to forced applies the next time users open the app.

Does it work with Expo?​

Yes. The SDK is plain JavaScript and uses @react-native-async-storage/async-storage, which Expo supports. Read the app version with expo-application.

What happens to users who are exactly on the minimum version?​

They're not asked to update. Only versions below the minimum are prompted.

Can I force an update on iOS but not on Android?​

Yes. Rules are per platform, so you can set different minimum versions for iOS and Android, for example while a release is still in review on one store.

What if the user has no internet connection?​

The check fails silently and the app opens normally. The prompt appears the next time the app starts with a connection.

Can I use it with native iOS or Android code?​

Yes, through the REST API: call GET /v2/versions on start and show your own update screen.