1--- 2title: Use Expo CLI 3description: Learn how and why you can use Expo CLI instead of @react-native-community/cli in any React Native project. 4--- 5 6import { Terminal } from '~/ui/components/Snippet'; 7import { Collapsible } from '~/ui/components/Collapsible'; 8import { BoxLink } from '~/ui/components/BoxLink'; 9import { DEMI } from '~/ui/components/Text'; 10 11To use Expo CLI in a project created with `npx react-native init`, you will first need to install the `expo` package. 12This package includes the Expo Modules API and Expo CLI. For a complete explanation of how to install this, see the [Install Expo modules](/bare/installing-expo-modules.mdx) guide. 13For most apps, it's as simple as running the following command in your project directory: 14 15<Terminal cmd={['npx install-expo-modules@latest']} /> 16 17## Why Expo CLI instead of `npx react-native` 18 19Expo CLI commands provide a number of benefits over the similar commands in `@react-native-community/cli`, including: 20 21- You can open up the Hermes debugger in one keystroke: <kbd>J</kbd>. 22- The debugger ships with React Developer Tools (`react-devtools`) already installed. 23- Support for [Continuous Native Generation](/workflow/prebuild.mdx) (CNG) with `npx expo prebuild` for easy upgrades, white-labeling, simple third-party package setup, 24 and improved maintainability of your codebase (by reducing the surface area). 25- Support for file-based routing with [`expo-router`](https://expo.github.io/router/docs). 26 - [Async bundling](/router/reference/async-routes) in development. 27- Built-in [environment variable support](/guides/environment-variables) and `**env** file loading. 28- View native logs directly in the terminal alongside your JavaScript logs. 29- Improved native build log formatting by using Expo CLI's own `xcpretty`-style tool that is built specifically for React Native apps. 30 For example, when compiling a Pod you can see which Node module included it. 31- [First-class TypeScript support](/guides/typescript). 32- Support for **tsconfig.json** aliases with `paths` and `baseUrl` [built-in to Metro](/guides/typescript#path-aliases). 33- [Web support](/guides/customizing-metro/#adding-web-support-to-metro) with Metro. Fully typed for React Native Web. 34- Modern [CSS support](/versions/latest/config/metro#css) with Tailwind, PostCSS, CSS Modules, SASS, and more. 35- Static site generation with Expo Router and Metro web. 36- Out of the box [support for monorepos](/guides/monorepos.mdx). 37- Support for Expo tooling such as [expo-dev-client](/develop/development-builds/introduction.mdx), the [Expo Updates protocol](/technical-specs/expo-updates-1.mdx) 38 and [EAS Update](/eas-update/introduction.mdx). 39- `npx expo run:ios` will invoke `pod install` automatically when needed. 40- `npx expo install` picks known compatible versions of dependencies for well-known packages. 41- `npx expo run:[android|ios]` and `npx expo start` automatically detect if an app is running on the default port and suggests another. 42- Select an Android or iOS device to launch into using <kbd>Shift</kbd> + <kbd>I</kbd> or <kbd>Shift</kbd> + <kbd>A</kbd> from the interactive prompt. 43- Built-in support for serving your app over an [ngrok tunnel](/develop/development-builds/development-workflows.mdx#tunnel-urls), 44- Develop on any port with any entry JavaScript file. 45 46We 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, 47macOS 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. 48 49## Compiling and running your app 50 51Once 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` 52and `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. 53 54## Starting the bundler 55 56`npx expo run:[android|ios]` will start the bundler/development server. You can skip that by passing in `--no-bundler` flag. 57Start the development server independently with `npx expo start` command. For SDK 48 and lower, use the `--dev-client` flag with the command. 58 59## Common questions 60 61<Collapsible summary="Can I use Expo CLI without installing the Expo Modules API?"> 62 63When 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, 64you can install the `expo` package with `npm install` and then configure your **react-native.config.js** to exclude the package from autolinking: 65 66```js 67module.exports = { 68 dependencies: { 69 expo: { 70 platforms: { 71 android: null, 72 ios: null, 73 macos: null, 74 }, 75 }, 76 }, 77}; 78``` 79 80> **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 or `expo-router`. 81 82</Collapsible> 83 84<Collapsible summary="Can I use prebuild for out-of-tree platforms, such as macOS or Windows?"> 85 86Yes! Refer to the [Customized Prebuild Example repository](https://github.com/byCedric/custom-prebuild-example) for more information. 87 88</Collapsible> 89 90## Learn more 91 92With the `expo` package installed and configured in your project, you can start using all features from Expo CLI and SDK. 93 94<BoxLink 95 title="Expo CLI Reference" 96 description="Learn more about the commands and flags available in Expo CLI." 97 href="/more/expo-cli" 98/> 99<BoxLink 100 title="Adopting Prebuild" 101 description={ 102 <> 103 Automate your native directories using the <DEMI>app.json</DEMI>. 104 </> 105 } 106 href="/guides/adopting-prebuild" 107/> 108<BoxLink 109 title="Using the Expo SDK" 110 description="Try out modules from the Expo SDK in your app" 111 href="/versions/" 112/> 113<BoxLink 114 title="Try Expo Router" 115 description="Expo Router brings the best routing concepts from the web to native Android and iOS apps." 116 href="https://expo.github.io/router/docs/" 117/> 118