start command launches Metro, the JavaScript bundler for React Native. Metro compiles your JavaScript code and serves it to your running app with support for Fast Refresh.
Usage
Options
| Option | Description | Default |
|---|---|---|
--port <number> | Port to run Metro on | 8081 |
--host <string> | Host to run Metro on | localhost |
--projectRoot <path> | Path to the project root | Current directory |
--watchFolders <list> | Additional folders to watch (comma-separated) | [] |
--assetPlugins <list> | Additional asset plugins (comma-separated) | [] |
--sourceExts <list> | Additional source extensions (comma-separated) | Default extensions |
--max-workers <number> | Maximum number of worker processes | CPU cores |
--transformer <string> | Custom transformer module path | Default transformer |
--reset-cache | Reset Metro bundler cache | false |
--resetCache | Alias for —reset-cache | false |
--custom-log-reporter-path <string> | Path to custom log reporter | None |
--https | Enable HTTPS server | false |
--key <path> | Path to custom SSL key | None |
--cert <path> | Path to custom SSL certificate | None |
--config <string> | Path to Metro config file | metro.config.js |
--no-interactive | Disable interactive mode | false |
Examples
Basic Usage
Custom Port
Reset Cache
- You’ve made native code changes
- Dependencies were updated
- Experiencing unexpected bundling errors
Custom Host
Watch Additional Folders
HTTPS Server
Limit Workers
Non-Interactive Mode
Interactive Mode
When Metro is running in interactive mode, you can use these keyboard shortcuts:| Key | Action |
|---|---|
r | Reload the app |
d | Open Developer Menu |
i | Run on iOS |
a | Run on Android |
j | Open debugger |
c | Clear Metro cache and reload |
q | Quit Metro |
Metro Server Output
When Metro starts successfully, you’ll see:Environment Variables
Custom Port
Node Environment
Common Use Cases
Development with Multiple Devices
Monorepo Setup
Performance Optimization
Troubleshooting
Port Already in Use
Error:Port 8081 is already in use
Solution:
Cache Issues
Error: Bundling errors or stale code Solution:Cannot Connect from Device
Error: Device shows red screen “Could not connect to Metro” Solution:Watchman Issues
Error: File watching errors Solution:Performance Tips
Reduce Initial Bundle Time
Reduce Initial Bundle Time
Use source maps only in development:
metro.config.js
Optimize for Large Projects
Optimize for Large Projects
Limit worker processes:
Speed Up Rebuilds
Speed Up Rebuilds
Enable persistent cache in
metro.config.js:Next Steps
Run iOS
Build and run your app on iOS
Run Android
Build and run your app on Android
Metro Config
Configure Metro bundler settings
Bundle
Create production bundles