React Getting Started

How to set up a React environment.

React Getting Started

To use React in production, you need npm which is included with Node.js.

To get an overview of what React is, you can write React code directly in HTML.

But in order to use React in production, you need npm which is included with Node.js.

Setting up a React Environment

If you have npx and Node.js installed, you can create a React application by using create-react-app.

Run this command to create a React application named my-react-app:

npx create-react-app my-react-app

The create-react-app will set up everything you need to run a React application.

Run the React Application

Run this command to move to the my-react-app directory:

cd my-react-app

Run this command to run the React application my-react-app:

npm start

A new browser window will open, and you will see your new React application.

Example

import React from 'react';
import ReactDOM from 'react-dom/client';

const myElement = <h1>I Love React!</h1>;

const root = ReactDOM.createRoot(document.getElementById('root'));
root.render(myElement);