Falytom logoFALYTOM
Games
ToolsUI ComponentsServicesProductsAbout
LoginSign Up
menu
  1. Home
  2. /Web Development
  3. /React
  4. /Setup Environment
Your Progress0%
0 of 42 completed

React Topics

Getting Started

  • What is React?
  • React vs Vanilla JavaScript
  • Setting Up Your Environment
  • Your First React App

JSX Fundamentals

  • Introduction to JSX
  • JSX Expressions and Variables
  • Conditional Rendering
  • Lists and Keys
  • Styling in JSX

Components Basics

  • Function Components
  • Props
  • Children Prop
  • Props Destructuring
  • Component Composition

State Management

  • Introduction to State
  • useState Hook
  • State Updates and Re-renders
  • Multiple State Variables
  • State Best Practices

Events and Interactivity

  • Handling Events
  • Event Objects
  • Forms in React
  • Form Validation

Side Effects and Data

  • Introduction to useEffect
  • Data Fetching
  • Cleanup Functions
  • Dependency Arrays

Advanced Hooks

  • useRef Hook
  • useContext Hook
  • useMemo Hook
  • useCallback Hook

React Patterns

  • Custom Hooks
  • Higher-Order Components
  • Render Props Pattern

React Router

  • Introduction to React Router
  • Routes and Navigation
  • Dynamic Routes and Parameters

Best Practices

  • Component Organization
  • Performance Optimization
  • Error Handling
  • Testing React Components

Real World Project

  • Building a Complete App

Setting Up Your Environment

Get ready to build React applications

Before we can start building amazing React applications, we need to set up our development environment. Don't worry - this process is straightforward, and we'll walk through every step together. By the end of this lesson, you'll have everything you need to create and run React apps on your computer!

What You'll Need

To develop React applications, you'll need three essential tools:

  1. Node.js - A JavaScript runtime that lets you run JavaScript outside the browser
  2. npm (Node Package Manager) - Comes with Node.js, helps you install and manage libraries
  3. A code editor - We recommend Visual Studio Code (VS Code), but you can use any text editor you prefer

Good news: All of these tools are completely free! And they work on Windows, Mac, and Linux.

Step 1: Installing Node.js and npm

Node.js is the foundation of modern JavaScript development. When you install Node.js, npm is automatically included. Let's get it installed!

For Windows Users

  1. Visit the official Node.js website: https://nodejs.org
  2. You'll see two download options: LTS (Long Term Support) and Current. Choose the LTS version - it's more stable and recommended for most users.
  3. Download the Windows Installer (.msi file) and run it
  4. Follow the installation wizard:
    • Click "Next" through the welcome screens
    • Accept the license agreement
    • Keep the default installation location (usually C:\Program Files\nodejs\)
    • Make sure "Add to PATH" is checked (it should be by default)
    • Click "Install" and wait for it to complete
  5. Click "Finish" when installation is complete

For Mac Users

  1. Visit https://nodejs.org
  2. Download the LTS version for macOS
  3. Open the downloaded .pkg file
  4. Follow the installation wizard:
    • Click "Continue" through the introduction
    • Accept the license agreement
    • Click "Install"
    • Enter your Mac password when prompted
  5. Wait for installation to complete and click "Close"

For Linux Users (Ubuntu/Debian)

Open your terminal and run these commands:

terminal
# Update package index
sudo apt update

# Install Node.js LTS version
curl -fsSL https://deb.nodesource.com/setup_lts.x | sudo -E bash -
sudo apt-get install -y nodejs

# Verify installation
node --version
npm --version

Verifying Your Installation

Let's make sure everything installed correctly. Open your terminal or command prompt and run these commands:

terminal
# Check Node.js version
node --version
# Should show something like: v20.11.0

# Check npm version
npm --version
# Should show something like: 10.2.4

āœ… Success!

If you see version numbers for both commands, congratulations! Node.js and npm are successfully installed on your computer.

Troubleshooting: If you get an error like "command not found" or "not recognized":

  • Windows: Restart your computer. The PATH environment variable needs to be refreshed.
  • Mac/Linux: Close and reopen your terminal, then try again.
  • If it still doesn't work, you may need to add Node.js to your PATH manually. Search online for "add Node.js to PATH [your-operating-system]" for detailed instructions.

Step 2: Installing a Code Editor

While you can write code in any text editor, we strongly recommend using Visual Studio Code (VS Code). It's free, powerful, and has excellent support for React development.

Installing VS Code

  1. Visit https://code.visualstudio.com
  2. Click the big download button for your operating system (Windows, Mac, or Linux)
  3. Run the downloaded installer
  4. Follow the installation wizard (you can keep all default options)
  5. Launch VS Code when installation is complete

Essential VS Code Extensions for React

VS Code becomes even more powerful with extensions. Here are the must-have extensions for React development:

How to Install Extensions

  1. Open VS Code
  2. Click the Extensions icon in the left sidebar (or press Ctrl+Shift+X on Windows/Linux, Cmd+Shift+X on Mac)
  3. Search for the extension name
  4. Click "Install"

Recommended Extensions

  • ES7+ React/Redux/React-Native snippets - Provides shortcuts for writing React code faster
  • Prettier - Code formatter - Automatically formats your code to look clean and consistent
  • ESLint - Helps you find and fix problems in your JavaScript code
  • Auto Rename Tag - Automatically renames paired HTML/JSX tags
  • Path Intellisense - Autocompletes file paths
  • GitLens - Enhances Git capabilities (optional but recommended)

šŸ’” Pro Tip

After installing Prettier, enable "Format On Save" in VS Code settings. Your code will automatically format every time you save a file - no more worrying about spacing and indentation!

Step 3: Creating Your First React App

Now for the exciting part - creating your first React application! We'll use Vite (pronounced "veet"), a modern build tool that's incredibly fast and perfect for React development.

Why Vite?

You might have heard of create-react-app - the traditional way to start React projects. While it's still valid, Vite has become the preferred choice because:

  • Lightning fast: Vite starts your development server in milliseconds, not seconds
  • Hot Module Replacement: See your changes instantly without losing component state
  • Modern: Uses the latest web standards and best practices
  • Optimized builds: Creates smaller, faster production bundles
  • Better developer experience: Cleaner output and better error messages

Creating a React App with Vite

Open your terminal or command prompt and follow these steps:

1. Navigate to Where You Want to Create Your Project

terminal
# On Windows
cd C:\Users\YourName\Documents

# On Mac/Linux
cd ~/Documents

# Or create a new folder for your projects
mkdir react-projects
cd react-projects

2. Create Your React App

terminal
npm create vite@latest my-first-react-app -- --template react

Let's break down this command:

  • npm create vite@latest - Uses npm to create a new Vite project with the latest version
  • my-first-react-app - The name of your project (you can change this to anything you like)
  • -- --template react - Tells Vite to use the React template

šŸ“ Project Naming

Project names should be lowercase with hyphens, no spaces. Good examples: my-app, todo-list, weather-dashboard

3. Navigate into Your Project

terminal
cd my-first-react-app

4. Install Dependencies

terminal
npm install

This command downloads and installs all the packages your React app needs. It might take a minute or two. You'll see a progress bar and lots of text scrolling by - that's normal!

5. Start the Development Server

terminal
npm run dev

You should see output similar to this:

terminal-output
  VITE v5.0.8  ready in 342 ms

  āžœ  Local:   http://localhost:5173/
  āžœ  Network: use --host to expose
  āžœ  press h + enter to show help

6. Open Your App in the Browser

Open your web browser and go to http://localhost:5173

šŸŽ‰ Congratulations! šŸŽ‰

If you see the Vite + React logo with a counter button, you've successfully created and launched your first React application!

Understanding Your Project Structure

Let's explore what Vite created for you. Open your project folder in VS Code (File → Open Folder), and you'll see this structure:

project-structure
my-first-react-app/
ā”œā”€ā”€ node_modules/        # All installed packages (don't touch this!)
ā”œā”€ā”€ public/              # Static files
│   └── vite.svg
ā”œā”€ā”€ src/                 # Your React code lives here
│   ā”œā”€ā”€ assets/          # Images, fonts, etc.
│   ā”œā”€ā”€ App.css          # Styles for App component
│   ā”œā”€ā”€ App.jsx          # Main App component
│   ā”œā”€ā”€ index.css        # Global styles
│   └── main.jsx         # Entry point of your app
ā”œā”€ā”€ .gitignore           # Files Git should ignore
ā”œā”€ā”€ index.html           # HTML template
ā”œā”€ā”€ package.json         # Project configuration and dependencies
ā”œā”€ā”€ package-lock.json    # Locked dependency versions
└── vite.config.js       # Vite configuration

Key Files and Folders Explained

node_modules/

Contains all the packages and dependencies your project needs. This folder can be huge (thousands of files!) but you never need to touch it. If you delete it, you can always restore it by running npm install.

public/

Static files that don't need processing. These files are served as-is to the browser. Put your favicon, robots.txt, or other static assets here.

src/

This is where you'll spend most of your time! All your React components, styles, and application logic go here.

src/main.jsx

The entry point of your React application. This is where React gets attached to your HTML page. Let's look at what's inside:

main.jsx
import React from 'react'
import ReactDOM from 'react-dom/client'
import App from './App.jsx'
import './index.css'

ReactDOM.createRoot(document.getElementById('root')).render(
  <React.StrictMode>
    <App />
  </React.StrictMode>,
)

This code:

  1. Imports React and ReactDOM
  2. Imports your main App component
  3. Imports global styles
  4. Finds the HTML element with id "root" and renders your App component inside it

src/App.jsx

Your main App component. This is the root component of your React application. You can modify this file to start building your own app!

index.html

The HTML template for your app. Notice it's very minimal - just a <div id="root"></div> where React will inject your entire application.

package.json

The heart of your project configuration. It lists your dependencies, scripts, and project metadata. Let's look at an important part:

package.json
{
  "name": "my-first-react-app",
  "version": "0.0.0",
  "scripts": {
    "dev": "vite",
    "build": "vite build",
    "preview": "vite preview"
  },
  "dependencies": {
    "react": "^18.2.0",
    "react-dom": "^18.2.0"
  },
  "devDependencies": {
    "@vitejs/plugin-react": "^4.2.1",
    "vite": "^5.0.8"
  }
}

The scripts section defines commands you can run:

  • npm run dev - Starts development server
  • npm run build - Creates production-ready files
  • npm run preview - Previews the production build

Making Your First Changes

Let's make a simple change to confirm everything is working and to see React's hot reload in action!

  1. Open src/App.jsx in VS Code
  2. Find the heading that says "Vite + React" and change it to something else, like "My First React App"
  3. Save the file (Ctrl+S or Cmd+S)
  4. Look at your browser - the change appears instantly!

⚔ Hot Module Replacement Magic

Notice how the page updated without a full refresh? That's Vite's Hot Module Replacement (HMR) in action. It updates only what changed, preserving your app's state. This makes development much faster!

Try making more changes - modify the count, change colors, add text. Every save instantly updates in your browser. This immediate feedback loop is one of the things that makes React development so enjoyable!

Common npm Commands You'll Use

Here are the commands you'll use most frequently in React development:

Starting and Stopping

terminal
# Start development server
npm run dev

# Stop the server (in terminal)
Ctrl + C  (then type 'Y' if asked)

Installing Packages

terminal
# Install a new package
npm install package-name

# Install a package as a dev dependency
npm install --save-dev package-name

# Install a specific version
npm install package-name@1.2.3

Building for Production

terminal
# Create production build
npm run build

# Preview production build
npm run preview

Cleaning Up

terminal
# Reinstall all dependencies (if something goes wrong)
rm -rf node_modules package-lock.json  # Mac/Linux
# or manually delete node_modules folder on Windows

npm install

Common Issues and Solutions

Here are some common problems you might encounter and how to fix them:

Port Already in Use

Error: "Port 5173 is already in use"

Solution: Either stop the other process using that port, or Vite will automatically try the next available port (5174, 5175, etc.).

Module Not Found

Error: "Cannot find module 'xyz'"

Solution: Run npm install to install missing dependencies.

Changes Not Appearing

Problem: You saved changes but don't see them in the browser

Solution:

  • Make sure you saved the file (look for the dot next to the filename in VS Code)
  • Check the terminal for error messages
  • Try refreshing the browser (F5)
  • Try stopping and restarting the dev server

Blank Page / White Screen

Problem: Browser shows a blank page

Solution:

  • Open the browser console (F12) and check for error messages
  • Make sure the dev server is running
  • Check that you're visiting the correct URL (http://localhost:5173)

Permission Errors

Error: "EACCES" or permission denied errors

Solution: Don't use sudo with npm commands. If you're getting permission errors, your npm might need to be reconfigured. Search for "fix npm permissions [your OS]" for detailed solutions.

Still Having Issues?

If you're stuck, don't worry! Check the error message carefully - it often tells you exactly what's wrong. You can also search the error message on Google or Stack Overflow. The React community is very helpful!

Next Steps: Optional Enhancements

Your environment is ready to go! But if you want to make it even better, here are some optional enhancements:

Git and GitHub

Version control is essential for any developer. If you haven't already:

  • Install Git: https://git-scm.com
  • Create a GitHub account: https://github.com
  • Initialize Git in your project:
terminal
git init
git add .
git commit -m "Initial commit"

# Create a repository on GitHub, then:
git remote add origin https://github.com/yourusername/your-repo.git
git push -u origin main

React Developer Tools

Install the React Developer Tools browser extension for Chrome or Firefox. This lets you inspect React components, view props and state, and debug your applications more easily.

  • Chrome: Search "React Developer Tools" in Chrome Web Store
  • Firefox: Search "React DevTools" in Firefox Add-ons

Additional VS Code Settings

Open VS Code settings (File → Preferences → Settings) and consider these helpful options:

  • Enable "Format On Save" (search for "format on save" in settings)
  • Set default formatter to Prettier (search for "default formatter")
  • Enable "Auto Save" (search for "auto save") - set to "afterDelay"

Key Takeaways

  • Node.js and npm are essential tools for React development
  • Vite is the modern, fast way to create React applications
  • VS Code with the right extensions makes React development much easier
  • The src/ folder is where you'll write most of your code
  • npm run dev starts your development server
  • Hot Module Replacement means changes appear instantly in your browser
  • package.json manages your project's dependencies and scripts
  • React Developer Tools help you debug React applications
  • Most issues can be solved by reading error messages carefully

What's Next?

Excellent work! You now have a complete React development environment set up and ready to go. You've created your first React app and seen it running in your browser. That's a huge milestone!

In the next lesson, we'll dive into your first React app and understand exactly what's happening in the code. We'll modify the default app, create our first custom component, and start building something real. Get ready to write some React code! šŸš€

šŸ“Œ Before Moving On

Make sure your development server is working and you can see changes appear instantly when you save files. This working environment is your foundation for everything we'll learn next!

Just set up my React development environment! Check out this guide!

Previous
React vs Vanilla JavaScript
Next
Your First React App

Never Miss a New React Tutorial

Join 2,000+ developers learning React step-by-step. Get new tutorials, tips, and exclusive resources delivered to your inbox - completely FREE.

You might also like

UI Components

Ready-made components for your projects

Developer Tools

Boost productivity with handy generators

HTML Game

Learn HTML concepts through interactive gameplay

Join Our Web Development Training Program

Master frontend & backend development with hands-on projects.

React Tutorials

0 of 42 completed

Your Progress0%

Topics

Getting Started

  • What is React?
  • React vs Vanilla JavaScript
  • Setting Up Your Environment
  • Your First React App

JSX Fundamentals

  • Introduction to JSX
  • JSX Expressions and Variables
  • Conditional Rendering
  • Lists and Keys
  • Styling in JSX

Components Basics

  • Function Components
  • Props
  • Children Prop
  • Props Destructuring
  • Component Composition

State Management

  • Introduction to State
  • useState Hook
  • State Updates and Re-renders
  • Multiple State Variables
  • State Best Practices

Events and Interactivity

  • Handling Events
  • Event Objects
  • Forms in React
  • Form Validation

Side Effects and Data

  • Introduction to useEffect
  • Data Fetching
  • Cleanup Functions
  • Dependency Arrays

Advanced Hooks

  • useRef Hook
  • useContext Hook
  • useMemo Hook
  • useCallback Hook

React Patterns

  • Custom Hooks
  • Higher-Order Components
  • Render Props Pattern

React Router

  • Introduction to React Router
  • Routes and Navigation
  • Dynamic Routes and Parameters

Best Practices

  • Component Organization
  • Performance Optimization
  • Error Handling
  • Testing React Components

Real World Project

  • Building a Complete App
Falytom logoFALYTOM

Learn technologies like HTML, CSS, JavaScript, React, NodeJS and more through interactive games, tutorials, components and free tools. Transform your businesses with AI chatbots, SEO-optimized websites, and professional development services.

Ā© 2025 Tomilola Group
  • Facebook logo
  • Twitter logo
  • Instagram logo
  • LinkedIn logo
  • GitHub logo
  • YouTube logo