In our command line, let's run npm install -g, for global, create-react-app. Now, from any directory, we can create a new react project by saying create-react-app and then, giving it the project name. In this case, let's call it Cool App.
Let's change directories into this new folder that's been created. Let's open this folder in our code editor.
Inside the package .json, we see a single development dependency of react scripts, our normal react production dependencies and then, three default scripts that we can run.
Back in the command line, let's run npm start. This will start up a server and open up our app in our default browser.
Here's the default view that says Welcome to React. Inside the source folder is where our components are located.
Let's go into this app.js file. Let's scroll down a bit. We can see, here, this Welcome to React code. Let's change that to say Hello World. When we saved our file, we saw that the app recompiled, and the browser was also automatically reloaded to show our new Hello World text.
When we make errors -- for example, if I remove this closing tag and re-save the file -- the command line will give helpful output to show where the error occurred.
When we're ready to ship our app, we can use the npm run build script to generate a production-ready folder. Now, if we look at the contents of our directory, we see this new build folder.
If at any point we no longer want to use the official react scripts, we can use the npm run eject script. Keep in mind that this action is permanent.
After running the eject script, we can see that the contents of our project had been modified to include a config folder, and our package .json has also been significantly modified.
In summary, use create-react-app with your project name to create a new project. Then, inside of that project, you can run npm start to start a development server, npm run build to create a production build, and npm run eject to opt out of react scripts.