Understanding the Structure of a React App

So you’ve created your first React app… now what’s all this stuff?
When you run npx create-react-app my-app
, it does a lot behind the scenes — setting up files, folders, and configurations. You open the project folder and boom — it looks more like a NASA launch system than a simple website.
Don’t worry — it’s way less scary than it looks. Let’s break it down, file by file, folder by folder.
The Top-Level Structure
When you open your project, you’ll see something like this:
my-app/
├── node_modules/
├── public/
├── src/
├── .gitignore
├── package-lock.json
├── package.json
└── README.md
node_modules/
This is where all your project's dependencies live — basically every package your app needs to run.
Don’t touch it.
Seriously. Let React handle this mess.
public/
Contains static files. The big one here is:
index.html
– The single HTML file React injects your entire app into. There's only one HTML page, and React updates the DOM using JavaScript magic.
Other files like favicon.ico
and manifest.json
live here too. You usually don’t touch this folder much unless you're adding assets.
src/
This is where your actual app lives — the files you’ll be working with the most. Let’s dig into what’s inside:
App.js
The heart of your app. It’s a component — think of it as the “main screen.” You can build other components and plug them into this one.
index.js
This file bootstraps the app — it tells React,
"Hey, take that <App />
component and render it into index.html
."
import React from 'react';
import ReactDOM from 'react-dom/client';
import App from './App';
const root = ReactDOM.createRoot(document.getElementById('root'));
root.render(<App />);
App.css
and index.css
These are just styling files. You can style your components directly here or later use CSS modules, styled-components, or Tailwind CSS (once you’re feeling fancy).
setupTests.js
/ reportWebVitals.js
These are used for testing and performance tracking. You can ignore them for now — we’re keeping things simple.
package.json
The brain of your app. It keeps track of:
Project name & version
All installed packages
Scripts like
npm start
ornpm run build
You’ll interact with this more as you add libraries and dependencies.
.gitignore
, README.md
, package-lock.json
.gitignore
– Tells Git which files to ignore (likenode_modules/
).README.md
– Info about your project.package-lock.json
– Keeps track of the exact versions of your installed packages.
So… What Should You Focus On?
Mainly these:
src/App.js
src/index.js
src/App.css
(or however you prefer styling)
That’s your sandbox. You’ll build components, pass props, manage state, and make magic happen here.
What’s Next?
Now that you understand the structure, you’re ready to start building! In the next post, we’ll look at React components — what they are, how they work, and how to build your first one from scratch.
Final Thoughts
React might seem overwhelming at first glance, but the more time you spend in it, the more it clicks. Focus on learning one thing at a time — it’s a journey, not a race.
Now go explore that src/
folder. Break stuff. Rebuild it. It’s the React way.
Subscribe to my newsletter
Read articles from Adeel Hussain directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
