Learn how and why you can use Expo CLI instead of @react-native-community/cli in any React Native project.
To use Expo CLI in a project created with npx react-native init
, you will first need to install the expo
package.
This package includes the Expo Modules API and Expo CLI. For a complete explanation of how to install this, see the Install Expo modules guide.
For most apps, it's as simple as running the following command in your project directory:
npx install-expo-modules@latest
npx react-native
Expo CLI commands provide a number of benefits over the similar commands in @react-native-community/cli
, including:
react-devtools
) already installed.npx expo prebuild
for easy upgrades, white-labeling, simple third-party package setup,
and improved maintainability of your codebase (by reducing the surface area).expo-router
.xcpretty
-style tool that is built specifically for React Native apps.
For example, when compiling a Pod you can see which Node module included it.npx expo run:ios
will invoke pod install
automatically when needed.npx expo install
picks known compatible versions of dependencies for well-known packages.npx expo run:[android|ios]
and npx expo start
automatically detect if an app is running on the default port and suggests another.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,
macOS and Windows — if you are building for those platforms, you can use Expo CLI for the supported platforms and @react-native-community/cli
for the others.
Once you have the expo
package installed, you can use the npx expo run:android
and npx expo run:ios
commands as alternatives to npx react-native run-android
and npx react-native run-ios
. You can pass in the --device
flag to select a device/simulator to build for — this also works for any connected iOS device.
npx expo run:[android|ios]
will start the bundler/development server. You can skip that by passing in --no-bundler
flag.
Start the development server independently with npx expo start --dev-client
.
When you install the expo
package with npx install-expo-modules
, you will also install the Expo Modules API. If you just want to try out Expo CLI for now,
you can install the expo
package with npm install
and then configure your react-native.config.js to exclude the package from autolinking:
module.exports = {
dependencies: {
expo: {
platforms: {
android: null,
ios: null,
macos: null,
},
},
},
};
Note: Not all features will work without the Expo Modules API installed. For example, you will not be able to use the
expo-dev-client
package orexpo-router
.
Yes! Refer to the Customized Prebuild Example repository for more information.
With the expo
package installed and configured in your project, you can start using all features from Expo CLI and SDK.
Learn more about the commands and flags available in Expo CLI.
Automate your native directories using the app.json.
Try out modules from the Expo SDK in your app
Expo Router brings the best routing concepts from the web to native Android and iOS apps.