To work with React first, you need to install node.js
on your local computer.
Install Node.js
it on your computer.
Go to nodejs.org website, and install the recommended version of node
Once the node is installed on your computer, check the node version in CMD by using node --version
a command. If you want to check the node package version use node --v
the command. Now we can install our React app
How many ways to create a React app
I will show you two different ways to install the React app.
Install the react app with npx
Install the react app with Vite
How to install react app with npx
This is the default method to create a React app which is documented in my React documentation.
React Doc: https://react.dev/learn/start-a-new-react-project
Open the folder where you want to create the React app.
Now open your PowerShell cmd by clicking
shift+right click
To create a react app using this command
npx create-react-app your-react-app-name
After running this command it will create your React app.
Note: It will take some time to create a React app.
Here is the Demo, I have created the first react app with a named first-react-app
After you create your react app on this app in your code editor, after opening in your code editor also open your code editor terminal to run this react app in your browser.
To run the react app in the browser use npm start
You will be redirected to http://localhost:3000/
Final Look in the browser
How to create a React app with Vite
Vite is a faster way to create a React app. To create React app with Vite follow these steps
Open the folder where you want to create the React app
Open your PowerShell cmd by clicking
shift+right click
Use command
npm create vite@latest
andpress Enter
After using this command
npm create vite@latest
it will ask for your project name as shown below imageAfter entering your project name,
press Enter
.Now it will ask you to select your framework. As we are creating create React app we will select React. To move the arrow use the
up & down key
Select React and
press enter
Now it will ask you to select a variant.
Select javascript and
press enter
Now you have successfully created your first React app using Vite.
Open your React app which is created with Vite in a code editor and also open the terminal to install the React dependencies node modules
Use
npm i
ornpm install
command to install the React dependencies node modulesWe have successfully installed node modules.
To run the Vite React app use
npm run dev
commandIt will redirect to http://localhost:5173/
Final Look
These are the two ways to create a React app.
Vite Doc: To create a React app with Vite
Thank you reading