Project Structure Explained in React js
React JS Project Structure
When you create a React project for the first time, the folder structure might look confusing. There are multiple files, different configurations, and folders like src, public, and node_modules. If you donβt understand what each part does, it becomes difficult to maintain the project as it grows.
A well-organized project structure is very important in real-world development. It keeps your code clean, scalable, and easier to manage when your application becomes large.
Basic React Project Structure (Using Vite)
When you create a React project using Vite, your folder structure generally looks like this:
my-react-app/
β
βββ node_modules/
βββ public/
β βββ favicon.ico
β
βββ src/
β βββ assets/
β βββ components/
β βββ App.jsx
β βββ main.jsx
β βββ index.css
β
βββ package.json
βββ vite.config.js
βββ index.html
Letβs understand each folder and file in detail.
1. node_modules
This folder contains all the installed dependencies. Whenever you run npm install, all packages get stored here.
You should never edit anything inside this folder manually. It is automatically managed by npm.
2. public Folder
The public folder contains static files that are not processed by React directly. For example:
- Images
- Icons
- Favicons
- Static HTML files
These files are served directly to the browser.
3. src Folder (Most Important)
The src folder is where most of your development happens. This is the heart of your React application.
main.jsx
This file is the entry point of your React app. It connects your React components to the HTML file.
import React from "react";
import ReactDOM from "react-dom/client";
import App from "./App";
ReactDOM.createRoot(document.getElementById("root")).render(
<React.StrictMode>
<App />
</React.StrictMode>
);
This file tells React where to render the application.
App.jsx
App.jsx is the root component of your application. Most developers use this file to structure the main layout or routing.
function App() {
return (
<div>
<h2>Welcome to My React App</h2>
</div>
);
}
export default App;
From here, you can import other components and build your UI.
components Folder
This folder is used to store reusable components. For example:
- Navbar.jsx
- Footer.jsx
- Button.jsx
- Card.jsx
Instead of writing everything inside App.jsx, you separate logic into smaller components.
assets Folder
The assets folder usually contains:
- Images
- Fonts
- Icons
- Static files
Keeping assets separate improves project organization.
4. package.json
This file contains project metadata and dependency information. It includes:
- Project name
- Version
- Installed packages
- Scripts (like npm run dev, npm run build)
Example scripts section:
"scripts": {
"dev": "vite",
"build": "vite build",
"preview": "vite preview"
}
5. index.html
This is the main HTML file where your React app gets mounted. It contains a root div:
<div id="root"></div>
React renders everything inside this div.
Organizing Large React Projects
As your application grows, you should organize folders more clearly. A better structure for medium or large projects might look like this:
src/
β
βββ components/
βββ pages/
βββ hooks/
βββ context/
βββ services/
βββ redux/
βββ utils/
βββ styles/
pages
Contains main page components like Home, About, Dashboard.
hooks
Stores custom React hooks.
services
Handles API calls and external integrations.
utils
Contains helper functions.
Why Proper Structure Matters
When you work alone on small projects, structure may not feel very important. But in real companies where multiple developers work together, clear project structure saves time and avoids confusion.
It improves:
- Code readability
- Team collaboration
- Maintainability
- Scalability
Common Mistakes Beginners Make
- Putting all code inside App.jsx
- Mixing API logic inside UI components
- Not separating reusable components
- Keeping everything inside one folder
Itβs always better to structure your project early instead of reorganizing later.
Final Thoughts
Understanding the React project structure is just as important as learning React concepts. When your folders are organized properly, your development becomes smoother and more professional.
A clean structure helps you think clearly, debug faster, and scale your application without creating chaos.
If you build the habit of writing organized code from the beginning, it will benefit you in every future project.

