Skip to content

Instantly share code, notes, and snippets.

@nandorojo
Last active June 24, 2022 00:47
Show Gist options
  • Save nandorojo/06d5fdf1dab83e3815114c38c93820da to your computer and use it in GitHub Desktop.
Save nandorojo/06d5fdf1dab83e3815114c38c93820da to your computer and use it in GitHub Desktop.
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