Skip to content

Instantly share code, notes, and snippets.

@nandorojo
Last active Jun 24, 2022
Embed
What would you like to do?
How to restart an Expo / Next.js app

If you need to restart a React Native app, and you're using Expo, then this gist will help you do it.

It also comes with web support.

Keep in mind, this will only work if you're using a custom dev client from Expo. If you aren't, then you should delete lines 11-13, and you won't be able to restart the app in dev mode.

import * as Updates from 'expo-updates'
import { Platform } from 'react-native'
const reload = () => {
if (Platform.OS === 'web') {
if (typeof window !== 'undefined') { window.location.reload() }
} else {
if (!__DEV__) {
Updates.reloadAsync()
} else {
import('expo-dev-menu/app/native-modules/DevMenu').then((menu) => {
menu.reloadAsync()
})
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment