I struggled a lot with deciding which method should I follow to create a react app. Previously everyone used to follow the cra or create-react-app method. But nowadays I prefer to use Vite. In this tutorial, I’m going to present both methods.
To install React using Create React App (CRA):
1. Make sure you have Node.js and npm (Node Package Manager) installed.
2. Open your terminal or command prompt.
3. Run the following command to install Create React App globally: npm install -g create-react-app
4. Once installed, create a new React app by running: npx create-react-app my-react-app
5. Change to the app's directory: cd my-react-app
6. Start the development server: npm start
To install React using Vite:
1. Make sure you have Node.js and npm (Node Package Manager) installed.
2. Open your terminal or command prompt.
3. Run the following command to install Vite: npm create vite@latest my-react-app -- template react
4. It will create a new directory named my-react-app for your Vite project and navigate into it: cd my-react-app
5. Install project dependencies: npm install
6. Start the development server: npm run dev