Setting Up Your Development Environment
Before you can start building with React, you need to set up your development environment. This lesson will guide you through installing the necessary tools.
Prerequisites
Installing Node.js and npm
Node.js is a JavaScript runtime that allows you to run JavaScript outside the browser. npm (Node Package Manager) comes bundled with Node.js and is used to install and manage packages.
Step 1: Download Node.js
Visit nodejs.org and download the LTS (Long Term Support) version for your operating system.
- Download the Windows Installer (.msi) from nodejs.org
- Run the installer and follow the installation wizard
- Verify installation by opening Command Prompt and running:
node --version
npm --version
Creating Your First React App
Now that you have Node.js and npm installed, you can create your first React application using Create React App or Vite.
Using Vite (Recommended)
Vite is the modern, faster alternative to Create React App:
bashnpm create vite@latest my-react-app -- --template react cd my-react-app npm install npm run dev
Success!
Your React app should now be running at http://localhost:5173. Open it in your browser to see your first React application!
Using Create React App (Alternative)
bashnpx create-react-app my-react-app cd my-react-app npm start
Understanding the Project Structure
After creating your app, you'll see this folder structure:
my-react-app/
├── node_modules/
├── public/
│ └── index.html
├── src/
│ ├── App.jsx
│ ├── App.css
│ ├── main.jsx
│ └── index.css
├── package.json
└── vite.config.js
Key Files Explained
- src/main.jsx
- Entry point of your application
- src/App.jsx
- Main React component
- package.json
- Project dependencies and scripts
- vite.config.js
- Vite configuration file
Video Tutorial
Next Steps
Next Lesson
JSX Syntax