Your First React App

React Tutorial

Your First React App – Step-by-Step Beginner Tutorial

Creating your first React app is an exciting moment for every web developer. React allows you to build modern, fast, and interactive user interfaces using reusable components. In this guide, you will create a working React application from scratch, understand how it runs, and modify it confidently.

This tutorial is perfect for beginners, students, and interview preparation.


 What Is a React App?

A React app is a JavaScript-based web application that renders UI using components instead of traditional HTML pages. Instead of refreshing the page again and again, React updates only the required parts of the screen.

Your first React app will:

  • Run on a local development server

  • Display UI using JSX

  • Use components

  • Auto-refresh when you change code


 Step 1: Install Required Tools

Before creating your first React app, you need:

 Node.js (Includes npm)

Download and install Node.js (LTS version).

Check installation:

node -v
npm -v

If both commands show version numbers, you’re ready.


 Step 2: Create Your First React App

The easiest and most beginner-friendly way is Create React App.

 Create the app

npx create-react-app first-react-app

 This may take a few minutes.

 Move into the project folder

cd first-react-app

 Start the app

npm start

 Your first React app opens automatically at:

http://localhost:3000

You’ll see the default React welcome screen.


 Step 3: Understanding the Default Project Structure

After creation, your folder looks like this:

first-react-app/
├─ public/
│ └─ index.html
├─ src/
│ ├─ App.js
│ ├─ index.js
│ ├─ App.css
│ └─ index.css
├─ package.json

 Important Files

FilePurpose
index.jsApp entry point
App.jsMain component
App.cssComponent styling
public/index.htmlRoot HTML

React injects everything into:


 Step 4: Your First React Component

Open src/App.js and replace its content:


 

export default App;

  •  Save the file
  •  Browser updates automatically
  •  No refresh needed

This is your first custom React UI


 Step 5: Understanding JSX

JSX allows writing HTML inside JavaScript.

Example:

Behind the scenes, React converts JSX into JavaScript.

JSX Rules:

  • One parent element

  • Use className instead of class

  • JavaScript inside { }


 Step 6: Adding a New Component

Create a new file: src/Welcome.js


 

Now import it into App.js:


 

  • This shows how React encourages reusable UI blocks

 Step 7: Using Props (Passing Data)

Props let you pass data to components.

Use it like this:

  •  Props are read-only
  •  Used for dynamic content

 Step 8: Adding State (Interactivity)

Let’s add a simple counter.


 

Add it to App.js:

  •  State makes your app interactive
  •  UI updates automatically

 Step 9: Styling Your First App

 Using CSS

Edit App.css:

Import it:

 Inline Styling


 Step 10: Build Your App for Production

When your app is ready:

npm run build
  •  Optimized files
  •  Faster loading
  •  Ready for deployment

 Common Beginner Mistakes

  •  Forgetting export default
  •  Writing multiple root elements
  •  Modifying state directly
  •  Mixing too much logic in one component

 What to Learn After Your First App?

Once your first app is done, learn next:

  • React Hooks (useEffect)

  • React Router

  • API fetching

  • Forms & validation

  • Project structure

  • Deployment (Netlify / Vercel)


 Summary

  •  Installed React
  •  Created first React app
  •  Understood components & JSX
  •  Added props and state
  •  Styled the app
  •  Built production version

Building your first app is the foundation of modern frontend development. Keep practicing small projects, and React will start feeling natural very quickly.

You may also like...