The Dev Server and Terminal UI

+15 Mana ✨

Once the project exists, the app on your device gets its JavaScript from the dev server that Expo CLI runs on your computer. The keys in its terminal open the app on devices and in tools, and its connection type decides which devices can reach it at all. When a phone scans the QR code and nothing loads, the Wi-Fi network and the connection type are the first things to check.

Key terms

  • Metro: the bundler that npx expo start uses by default to build your JavaScript.
  • Terminal UI: the interface npx expo start shows, with a QR code for the dev server URL and a list of keyboard shortcuts.
  • Host type: how devices connect to the dev server, one of lan, localhost or tunnel, chosen with --host or with flags such as --tunnel.
  • Tunnel: a connection through a public URL that lets a device on any network reach the dev server.

Starting the server

Run npx expo start in the project folder (yarn expo start, pnpm expo start and bun expo start work too). start is the CLI's default command, so npx expo alone does the same thing, and the template's start script runs expo start as well. The server listens on http://localhost:8081 and bundles with Metro.

Three settings change how it starts:

  • --port (-p) moves the server off port 8081, and --port 0 takes the first available port.
  • --clear (-c) clears the bundler cache as the server starts.
  • CI=1 in the environment turns off file watching and Fast Refresh, so your edits don't reach the app until you restart. If changes stop showing up, check that CI isn't set in your shell.

Keys that drive the server

The Terminal UI prints a QR code for the dev server URL, and scanning it with your phone opens the app there. While the server runs, single keys act on it:

KeyAction
AOpen the project on a connected Android device or emulator
Shift+AChoose which Android device or emulator to open
IOpen it in the iOS Simulator (the key appears only on macOS)
WOpen it in a web browser
RReload the app on every connected device
JOpen React Native DevTools for a connected device that uses Hermes
MOpen the dev menu on connected native devices
OOpen the project code in your editor
CClear the terminal and print the dev server info and QR code again
?Show all Terminal UI commands

When no app that uses Hermes is connected, J prints a warning that React Native DevTools can only be used with Hermes. The Terminal UI table in the Expo CLI docs gives E as the key that shows the QR code, but the CLI has no E handler, so press C.

LAN, localhost and tunnel

By default the server uses the lan host type, and the phone loads the app over your local network. --host (-m) sets the host type, and the --lan, --localhost and --tunnel flags select one directly. The CLI accepts only one of --offline, --host, --tunnel, --lan and --localhost per command.

With --localhost, Metro listens on 127.0.0.1, the loopback address, so a phone on the network can't reach the server.

--tunnel connects through an Expo tunnel that works from any network. A bare --tunnel means --tunnel=expo, and --tunnel ngrok selects ngrok, which the CLI calls the legacy option. The Tunneling section of the Expo CLI docs still asks you to install @expo/ngrok first, and that step only applies to the legacy provider. The Expo tunnel is tied to your Expo account: if the CLI can't get a signed URL because you aren't logged in, the error tells you to run npx expo login or to use --tunnel ngrok.

A tunnel's URL is public and reachable by any device with a network connection, and reloads are much slower than over LAN or localhost, so use it only when LAN fails. It also needs a network connection on both devices, which rules out combining it with --offline.

--offline stops the CLI from making network requests and turns on by itself when the computer has no internet. It still serves the app over LAN.

The npx expo start variations show these flags side by side. When a phone can't open the app, first check that it is on the same Wi-Fi network as the computer. Public Wi-Fi restrictions and firewalls can still block a device from reaching the server over LAN, and router configuration is a common cause on public networks. In that case, restart with npx expo start --tunnel and scan the new QR code.

The .expo folder

The first time the dev server starts in a project, it creates a .expo directory at the project root. Inside, devices.json records the devices that recently opened the project, and settings.json holds the server configuration used to serve the manifest. The CLI also writes a README there, which lists a dev/logs/ folder of structured JSONL logs from CLI commands, truncated on each run.

These files are specific to your computer. The template's .gitignore lists .expo/, and the README in the folder says not to commit it.

Code Examples

bash
# Default: LAN, on http://localhost:8081
npx expo start

# Clear the bundler cache and take the first free port
npx expo start --clear --port 0

# Only reachable from this computer (Metro listens on 127.0.0.1)
npx expo start --localhost

# Through an Expo tunnel (needs npx expo login)
npx expo start --tunnel

# Through the legacy ngrok provider
npx expo start --tunnel ngrok
✓ Completed