Expo Local Development Guide

Debug React Native applications on localhost using Expo, with Metro Bundler defaulting to port 8081 and Dev Tools commonly on port 19000.


Expo is a React Native development platform that simplifies building, debugging, and OTA updates. During local development, Metro Bundler serves the JS bundle on localhost, while real devices or simulators connect via LAN or tunnel.

Quick Start

npx create-expo-app my-app
cd my-app
npx expo start

The terminal will display a QR code and the Dev Server URL.

Common localhost Ports

PortPurpose
8081Metro Bundler (http://localhost:8081)
19000Expo Dev Tools (legacy/some configurations)
19006Web Preview (Expo for Web)

Refer to the output from expo start.

Debugging Methods

MethodDescription
Expo GoScan the QR code to access Metro on your computer via LAN
iOS SimulatorPress i to open
Android EmulatorPress a to open
WebPress w to open the local web version in a browser

Coordinating with Backend APIs

Accessing host machine APIs from the simulator:

  • Android Emulator: http://10.0.2.2:3000 (not localhost)
  • iOS Simulator: can use http://localhost:3000
  • Real Device: use the computer’s LAN IP, such as http://192.168.1.10:3000

Frequently Asked Questions

Port 8081 is occupied
Run npx expo start --port 8082 or terminate the old Metro process.

Unable to connect to real device
Check the firewall; try expo start --tunnel (slower but penetrates NAT).

Summary

The core of Expo local development is Metro @ localhost:8081, used in conjunction with simulators or Expo Go to debug React Native; the web preview occupies another port such as 19006.

访客计数:------ Best viewed in Netscape Navigator · 800×600 © LocalHost Run