How to start with react js


React JS is a javascript library. To start with react, first you have to install latest version of node js. After node js installed, open your command prompt and run below command for installing react as globally:

npm install -g create-react-app

The above command will install create-react-app globally in system. Now from any directory you can run the below command from command propmt:

create-react-app first_react_example

Here first_react_example is your project name. By running this command it will create a directory and install all dependencies of react js. Now in your first_react_example directory you can see the below structure:

-first_react_example
-node_modules
-public
-index.html
-manifest.json
-favicon.icon
-src
-App.css
-App.js
-App.test.js
-index.css
-index.js
-logo.svg
-registerServiceWorker.js
-.gitignore
-package.json
-package-lock.json
-README.md

This is the default structure of react project. 

To start project in your command prompt go inside project folder and run below command:

npm start

The above command will start your development server for react project. It will open a default page on your browser like below:

First React App

Congratulations!!! Your first react project is running now.

2 comments

  • Rajat

    very nice explanation , thanks

  • Sumit

    Very nice example

Leave a comment

Please note, comments must be approved before they are published