Programmatically Restart a React Native App

Solution 1:

If you want to restart just the JS part, then you can use React Native Restart Package. This will work on both Android and iOS.

If you want to restart the whole application, There are no react native packages as of now. If you want to create on your own, then check the following link

Building the custom Android module for React Native

If you find difficulty in writing the base JAVA code, You can generate the boilerplate using React Native Create Library

UPDATE:

From 0.62, React Native have added DevSettings.reload(). So, if you want to reload programmatically while developing you can use that. Note that this method does not work in production!

Click here for Doc

Solution 2:

In addition to what's been said above, you can restart the app using Codepush like so:

import CodePush from 'react-native-code-push';
CodePush.restartApp();

In fact, that's where React Native Restart Package got its code from.

Solution 3:

For iOS, React Native exposes a "reload" method via "DevSettings" https://github.com/facebook/react-native/blob/75f2da23c5d557862cf4b7bcdd8a1445b54d1c31/React/Modules/RCTDevSettings.mm#L240-L243

import { NativeModules } from "react-native";


NativeModules.DevSettings.reload();

Solution 4:

You can use ReactInstanceManager like this

final ReactInstanceManager instanceManager = getReactInstanceManager();
instanceManager.recreateReactContextInBackground();