I am using create-react-app and hosting in its default port localhost:3000 and want to access this from another device on the same network.
I got the IP of my host's IP (using ifconfig) 192.168.0.5 and tried opening 192.168.0.5:3000 but that did not work.
Is there any way to achieve this?
Simply pull up your device's browser and type in the IPv4 Address you copied down earlier followed by a colon and then the port number. The format should look something like the following: 555.55. 55.555:1234 once you hit enter, you should see your React App live on your mobile device!
Approach: We can easily view React App on different devices. We need to find out the IP address of our device using ipconfig command in Windows cmd. After that, we can access that URL from any device and we will be able to view this page in our device but provided both are on the same network.
1 Answer. Show activity on this post. For me it worked to just copy the project and then run 'npm install' on the other computer.
To change the default port for a create-react-app project, update the start command in your package. json file to specify the port, e.g. "PORT=3456 react-scripts start" on macOS and Linux and "set PORT=3456 && react-scripts start" on Windows.
Simply run HOST=0.0.0.0 npm run start
.
Afterwards open the url from another device on the network.
In your case, 192.168.0.5:3000
would work.
Documentation for setting HOST environment variables.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With