How to view React App in a different devices ?
Usually, when we create a react-app, we used to view it at localhost:3000. In this article, we will see how to view React App in a different 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.
Prerequisite: All devices are connected to same wifi.
Below is the step-by-step implementation.
Step 1: Create a react application using the following command.
npx create-react-app foldername
Step 2: Once it is done, change your directory to the newly created application using the following command.
Project Structure: It will look like the following.
Step 3: Now write down the following code in App.js file.
Step 4: We will simply create the component GFG.jsx.
Step to run the application: Enter the following command to run the application.
Step 5: Now we will access this app from mobile. For this, first find out ip of your device using ipconfig command in Windows cmd.
After finding your ip: suppose 255.255.255.0. Now access url 255.255.255.0:3000 from any device. You will be able to view this page in your device (provided both are on same network)
Just see a glimpse of react app in mobile phone.