Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to open a create-react-app from another computer connected to the same network?

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?

like image 747
ambar Avatar asked Nov 21 '17 11:11

ambar


People also ask

How do you access the React app on the same network?

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!

How do I access local create-React-app from another computer?

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.

How do I move my React project to another computer?

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.

How do I open the React app in another port?

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.


1 Answers

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.

like image 157
Elad Avatar answered Oct 05 '22 23:10

Elad