Creating and Running React Projects With create-react-app

Creating and Running React Projects With create-react-app

Create React App

In the previous tutorial, we explored how react can be added to a HTML website from the CDN. In this section we will explore the second and probably the most popular way of using the React JS library: React as a single page application using the create-react-app command.

Create React App is a comfortable environment for learning React, also according to ReactJS official documentation, It is the best way to start building a new single-page application in React.

Using Create React App sets up your development environment with no stress, giving you the ability to use the latest JavaScript features. It does not only provide a nice developer experience; it also optimizes your app for production.

Running Create React App on the CLI, requires that you have Node >= 6 and npm >= 5.2 on your machine.

To get started, install create-react-app on your local machine globally from npm via the cli using the following commands:

npm install -g create-react-app

After the installation, quickly create your desired awesome react application using this command    

create-react-app example-app
cd example-app

Building and running an application

Inside of your application’s folder, you can run the following commands

npm start

Runs the app in development mode. Open http://localhost:3000 to view it in the browser.

The page will reload if you make edits. You will also see the build errors and lint warnings in the console if any.

Create React App doesn’t handle backend logic or databases; it just creates a frontend build pipeline, so you can use it with any backend you want. Under the hood, it uses Babel and webpack to spin up your application.

Join the discussion

1 comment

Vivvaas’ Corner

Learn skills that matters from a community of talented developers and writers whose joy is to write in a way that you will understand.