Saturday, August 30, 2025

How to start 'metro' (React Native)

To See All React Native Articles: Index of Lessons in Technology

Good question 👍
The Metro bundler is the JavaScript packager that React Native uses. It must be running in the background for your app to load JS code.


🚀 How to start Metro bundler

  1. Go to your React Native project root (where package.json is).

    bash
    cd ~/Desktop/your_project_name
  2. Start Metro:

    bash
    npx react-native start
    • By default, Metro will run on port 8081.

    • Leave this terminal window open.

  3. In another terminal, build & install the app:

    bash
    npx react-native run-android

    or

    bash
    npx react-native run-ios

🌐 For wireless debugging

If you’re not using USB, run Metro with your laptop’s IP address:

bash
npx react-native start --host <your-laptop-ip>

Then configure your phone (Dev Settings → Debug server host & port) with:

makefile
<your-laptop-ip>:8081

⚡ Pro tip: If you already ran npx react-native run-android, Metro usually auto-starts in another tab. But if you closed it, just re-run npx react-native start.


Do you want me to also show you how to make Metro auto-restart whenever you run run-android, so you don’t have to open it manually each time?

No comments:

Post a Comment