Before building React applications, you must set up a development environment. Two of the most popular tools for bootstrapping React projects are:
Both provide pre-configured environments with React, JSX, and live reloading, so you can start coding immediately without manual bundler or tooling setup.
src/, public/, and package.json keep your app organized.Step 1 · Check Node.js
Install Node.js (v16 or newer). Then verify that Node.js and npm are installed:
// Check installed Node.js and npm versions
node -v
npm -v
Step 2 · Create Vite + React Project
Use the official Vite scaffolding command to create a new React app:
// Create a new React project using Vite
npm create vite@latest my-react-app
cd my-react-app
During setup, choose framework → React and variant → JavaScript (or TypeScript if you prefer).
Step 3 · Install Dependencies & Start Dev Server
Install all required packages and run the development server:
// Install dependencies and run the Vite dev server
npm install
npm run dev
The app will start at a local address such as http://localhost:5173/ (shown in your terminal).
Step 1 · Create Project with npx
Use npx (runs the package without installing globally) to create a CRA project:
// Create a React project using Create React App
npx create-react-app my-react-app
cd my-react-app
Step 2 · Start the Dev Server
Start the development server with:
// Start the CRA development server
npm start
CRA will automatically open your app at http://localhost:3000/ in the browser.
Step 3 · Basic CRA Project Structure
src/ – Your React components and app logic.public/ – Static files and the main index.html.package.json – Manages dependencies and npm scripts.After creating a project (Vite or CRA), you usually edit the main App.jsx or App.js file to change what is rendered on the screen.
// Simple React component that shows a welcome message
function App() {
return (
<div>
<h1>Welcome to my React app!</h1>
<p>This project was created using Vite or CRA.</p>
</div>
);
}
export default App;
When you save this file, the dev server (Vite or CRA) will automatically refresh the browser or update the UI using hot module replacement (HMR).
| Feature | Vite | Create React App (CRA) |
|---|---|---|
| Build & Dev Speed | Very fast (dev server + HMR optimized with ESBuild) | Slower (startup and rebuild times are longer) |
| Configuration | Flexible, lightweight config via vite.config.js |
Zero-config but limited deep customization without ejecting |
| Production Build Size | Smaller and highly optimized by default | Often larger builds out-of-the-box |
| Recommended For | Modern React projects and fast prototyping | Beginners and legacy projects already using CRA |
npm run dev (Vite), you’ll see a URL like http://localhost:5173/. Opening it shows the default Vite + React welcome screen.npm start (CRA), your browser opens http://localhost:3000/ with the CRA starter page.App.jsx/App.js immediately updates the browser without a full refresh thanks to HMR.localhost:5173.App.jsx (or App.js) to display your name and a custom welcome message.