Skip to Content

File & Folder Structure of a React App

When you open a React project for the first time, it can look a little overwhelming - so many files, so many folders. But here’s the truth: once you actually understand what each of them does, the whole structure starts making perfect sense.

Let’s break it down - clean, simple, and practical 👇


The Heart of Your Project

This file defines your project’s identity. It contains details like:

  • The project name, version, and description
  • Scripts to build, start, or test the app
  • The list of dependencies and devDependencies

It’s what npm or yarn uses to know what your app needs to run or build.


Dependencies

These are the packages your app needs to run in production — like React, ReactDOM, or Axios. Without them, your app won’t even start.

DevDependencies

These are used only during development — tools that make coding easier, like ESLint, Vite, or Babel. They don’t go to production, but they help maintain clean, optimized code.

All these dependencies are stored in the node_modules folder (which gets automatically created when you run npm install).

package-lock.json - The Version Keeper

This file ensures consistency. It locks down the exact versions of every dependency (and their sub-dependencies).

So, if you install the same project on another computer, everything works the same way.

No “it works on my machine” moments here.

README.md - Your Project’s Story

This file is for humans, not computers.

It’s the first thing anyone reads when they open your repo. Usually, it includes:

  • What your project does
  • How to install and run it
  • Any extra notes or author info

A good README makes your project look professional and easy to understand.

vite.config.js -Power Behind the Build

Since most React projects today use Vite for faster builds, this file defines how Vite behaves.

You can set things like:

  • File path aliases
  • Plugins to enhance build performance
  • Custom server ports

Basically, it’s your project’s configuration brain.

eslint.config.js - Code Quality Guard

Every developer’s silent helper.

It stores ESLint rules, which keep your JavaScript code consistent and bug-free.

It’ll warn you if your code doesn’t follow proper syntax, has unused variables, or naming issues.

Clean code = smooth teamwork.

.gitignore - What Git Should Ignore

Not every file should be uploaded to GitHub.

This file tells Git what to ignore, like:

  • node_modules/ (too huge)
  • env (contains secrets)
  • dist/ or build/ (auto-generated)

Keeping your repo clean and lightweight.

Project Files Overview

index.html

This is the only HTML file your React app needs.

It’s where the React app mounts — the div with id="root" lives here.

main.jsx

This file connects React with the browser.

It renders the <App /> component inside the root div — your app’s entry point.

App.jsx

The main React component.

It’s the parent of all other components — the heart of your UI.

App.css & index.css

Your styling files.

index.css is for global styles, while App.css is usually specific to the App component.

Best Practices

  • Always keep your components inside the src/components for easy organization.
  • Use the public folder for assets that need to be directly accessible (like favicon or images).
  • For files used inside the app (like icons, CSS, or logos), create an assets folder inside src.

This keeps your project clean and easy to scale.

node_modules -The Big Library

This folder stores all your project’s installed dependencies.

It’s huge and automatically created when you run npm install.

You’ll never edit anything here manually — just let npm handle it.

Why You Should Not Push node_modules to Git

  • It’s massive in size
  • Everyone can recreate it easily by running npm install
  • Uploading it wastes storage and slows down cloning

Instead, just push the package.json and package-lock.json files — that’s all GitHub needs.

 Final Thought:

Understanding your React project’s file structure isn’t just theory — it’s what helps you navigate, debug, and build faster.

Once you get comfortable with these files, you’ll never feel lost opening a new React project again.

Commenting is not enabled on this course.