Edit this page
Learn how to migrate to use Expo CLI instead of @react-native-community/cli in any React Native project.
Edit this page
To migrate from npx react-native init
to Expo CLI, you'll need to install the expo
package, which includes the Expo Modules API and Expo CLI. This guide covers the installation step, the benefits of using Expo CLI, and how to compile and run your project after migrating to Expo CLI.
It is strongly recommended to use Expo CLI when using other Expo tools. It is required for many tools, such as EAS Update, Expo Router, and expo-dev-client, and other features may not work as well without it.
expo
packageIn most cases, executing the following command in a project directory to install the package is all you need to do:
-
npx install-expo-modules@latest
For a detailed installation guide, see Install Expo modules.
npx react-native
Expo CLI commands provide several benefits over the similar commands in @react-native-community/cli
, which includes:
react-devtools
) already installed.expo prebuild
for upgrades, white-labeling, easy third-party package setup, and better maintainability of the codebase (by reducing the surface area).expo-router
.
xcpretty
-style tool built specifically for React Native apps. For example, when compiling a Pod, you can see which Node module included it.paths
and baseUrl
built-in to Metro.expo-dev-client
, the Expo Updates protocol and EAS Update.pod install
execution when using npx expo run:ios
.npx expo install
selects compatible dependency versions for well-known packages.npx expo run:[android|ios]
and npx expo start
. If another app is running on the default port, a different port is used.We recommend Expo CLI for most React Native projects that target Android, iOS, and/or web. It does not yet have built-in support for the most popular out-of-tree platforms, such as
Windows and macOS. If building for these platforms, you can utilize Expo CLI for the supported platforms and @react-native-community/cli
for the others.
After installing the expo
package, you can use the following commands which are alternatives to npx react-native run-android
and npx react-native run-ios
:
# for Android
-
npx expo run:android
# for iOS
-
npx expo run:ios
When building your project, you can choose a device or simulator by using the --device
flag. This also applies to any iOS device that is connected to your computer.
npx expo run:[android|ios]
automatically starts the bundler/development server. If you want to independently start the bundler with npx expo start
command, pass the --no-bundler
to the npx expo run:[android|ios]
command.
Expo Modules API is also installed when you install the expo
package with npx install-expo-modules
. If you want to try out Expo CLI for now without installing Expo Modules API, install the expo
package with npm install
and then configure the react-native.config.js to exclude the package from autolinking:
module.exports = {
dependencies: {
expo: {
platforms: {
android: null,
ios: null,
macos: null,
},
},
},
};
Note: Without Expo API Modules installed, certain features such as
expo-dev-client
orexpo-router
are unavailable.
Yes! Refer to the Customized Prebuild Example repository for more information.
Now, with the expo
package installed and configured in your project, you can start using all features from Expo CLI and SDK. Here are some recommended next steps to dive deep:
Learn more about the commands and flags available in Expo CLI.
Automate your native directories using the app.json.
Try out libraries from the Expo SDK in your app.
Expo Router brings the best routing concepts from the web to native Android and iOS apps.