Automatically set a debug server host & port for device in react-native apps

mbob picture mbob · Jun 12, 2019 · Viewed 9.3k times · Source

Is there a way to automatically set the Debug server host & port for device in react-native apps?

I have to trigger this menu and set a proxy for my app and I want it to be done automatically when the app is installed. Is that possible?

enter image description here

Answer

Nick Bull picture Nick Bull · Mar 14, 2021

I wrote a little package for this because it was driving me nuts. Check it out here:

npm i @nick-bull/react-native-debug-address

# DEBUG_HOST=127.0.0.1:8081 npx react-native start --port 8081
# or, equivalently
DEBUG_PORT=8081 npx react-native start --port 8081

npx react-native run-android --port 8081