How to start a React.js application?

How to create a Hello World app in React.js »

After initiating the React project, you’ll have various files and folders created in your project directory. Let’s break them down one by one:To start your React app, make sure you are inside the correct project directory and run the following command line command:

npm start

If everything goes well, you should see something like this in the Terminal/CMD window:

Next up, it should automatically open your default web browser and redirect you to http://localhost:3000/ where you’ll see something like this:

welcome

To stop the React app, go back to your Terminal window and press Ctrl + C or Cmd + C.

Theres’s a chance you might run into erors while running the React server for the first time. And it’s totally normal. Here I’ve discussed some of the possible issues you might run into:

Fixes for React server issues

Q. I’m getting an error: Something is already running on port 3000. Would you like to run the app on another port instead?

If you encounter a similar message, you can either stop the other server (where an instance of React app is already running) or you can type Y and press the Enter key to run the application on another port. If you press Y, it’ll run the application on another port (most possibly, port 3001).

Q. Localhost 3000 doesn’t show anything on the screen. What should I do?

There’s a chance that localhost:3000 may not show anything. There is a easy fix for that. Go back to your Terminal window and note the IP address after “On Your Network”. For example, in my case, the address is http://192.168.56.1:3000. You can go to that address instead of localhost:3000 and it should work just fine.