React — Setup
Prerequisites
Before setting up React, make sure you have:
- Node.js (version 14 or higher)
- npm or yarn
- Code editor (VS Code recommended)
Installing Node.js
Download Node.js from nodejs.org. This installs npm (Node Package Manager).
# Check Node.js version
node --version
# Check npm version
npm --version
Creating a React Project
# Using npx (recommended)
npx create-react-app my-app
# Using yarn
yarn create react-app my-app
Using Vite (Faster)
# Create with Vite
npm create vite@latest my-app -- --template react
# Install dependencies
cd my-app
npm install
# Start dev server
npm run dev
Project Configuration
// package.json
{
"name": "my-app",
"version": "1.0.0",
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test"
},
"dependencies": {
"react": "^18.2.0",
"react-dom": "^18.2.0"
}
}
VS Code Extensions
Install these extensions for better development:
- ES7 React/Redux/GraphQL/React-Native snippets
- Prettier - Code formatter
- ESLint
- Auto Rename Tag
Mini Practice
Set up a React project that:
- Creates a new React app with Vite
- Installs dependencies
- Starts the development server
- Opens the app in browser
Up Next
Next: Learn about JSX syntax.
Related Topics
Frequently Asked Questions about Setup
What is Setup in React?
Setup is a fundamental concept in React. This lesson explains it step by step with clear examples, making it easy for beginners to understand.
How do I learn Setup?
Start by reading the explanation above, then try the code examples. Practice by modifying the examples and experimenting with different values. Hands-on practice is the best way to learn Setup.
Why is Setup important in React?
Setup is essential for React development. Understanding this concept will help you write better code and solve real-world problems more effectively.