Starting up a React project from scratch is a daunting task as it requires many configurations and dependencies to be setup just before we start to write even a single line of code. create-react-app developed by Facebook comes to solve this problem and today we are going to see how to create new project using create-react-app.
In order to start a new project from scratch in React, it requires including lot of dependencies like Babel, webpack, etc. and configuring these dependencies are a hefty task for beginners to React as a small misconfiguration might end up with errors. For beginners learning React and for making the development process an easy one, the create-react-app comes in handy. The create-react-app creates all the basic files and handles the task of including all the dependencies and packages required to kick start a basic React project.
To create a new React project using create-react-app enter the following:
create-react-app project-name
Executing the above command will start to create all the boilerplate codes, files and configurations required for a basic React project inside the folder “project-name”. Once the execution is completed, you will need to go to the folder “project-name” using the “cd project-name” command. Here you can find the files that are generated and created by the create-react-app tool. In order to start the project, run the following command while you are inside the “project-name” folder:
npm start
After executing the above npm start command, the browser will be opened automatically and will display the default create-react-app page: