React Folder Structure
React Folder Structure explains scalable frontend organization through feature boundaries, shared UI, pages, hooks, services, types, utilities, assets, dependency direction, co-location, team ownership, and enterprise architecture.
Learning Objectives
By the end of this lesson, you will be able to:
- Understand why folder structure matters in React applications.
- Understand the difference between project structure and application architecture.
- Understand the purpose of
src,public, and configuration files. - Organize components effectively.
- Understand feature-based folder organization.
- Separate reusable UI from business-specific components.
- Organize pages, hooks, services, utilities, types, and assets.
- Understand dependency direction between folders.
- Design a scalable structure for medium and large React applications.
- Avoid common folder-structure mistakes.
- Understand how folder structure affects team scalability.
- Design a React structure suitable for an enterprise application.
- Explain folder-structure decisions confidently in interviews.
Introduction
A React application can start very simply:
src/├── App.tsx└── main.tsx
That is perfectly fine.
But after a few months, a real application might contain:
200+ Components50+ Hooks100+ API Functions30+ PagesMultiple Business DomainsShared UIAuthenticationState ManagementTestingAnalyticsFeature Flags
If everything is placed into a few folders without clear boundaries, the project becomes difficult to understand.
For example:
src/└── components/├── Button.tsx├── CourseCard.tsx├── PaymentForm.tsx├── UserProfile.tsx├── Dashboard.tsx├── Login.tsx├── AdminPanel.tsx├── useAuth.ts├── api.ts├── utils.ts└── ...
This technically works.
But it doesn't communicate the architecture.
A good folder structure should answer:
Where does this code belong, who owns it, and what is it allowed to depend on?
Folder Structure Is Not Architecture
This distinction is extremely important for senior engineers.
A folder structure describes:
Where files live
Architecture describes:
ResponsibilitiesDependenciesBoundariesData flowCommunicationOwnershipRuntime behavior
For example, this looks organized:
src/├── components/├── services/├── hooks/└── utils/
But it doesn't tell us:
Who can import whom?Which code belongs to which business domain?Where should authentication logic live?Can payment code directly access course internals?
Therefore:
A clean folder structure can support good architecture, but it does not automatically create good architecture.
Start With the Basic Structure
A new React + TypeScript + Vite project may look approximately like:
techlearningpro-react/│├── public/│├── src/│ ├── assets/│ ├── App.tsx│ ├── App.css│ ├── index.css│ └── main.tsx│├── .gitignore├── index.html├── package.json├── package-lock.json├── tsconfig.json├── tsconfig.app.json├── tsconfig.node.json└── vite.config.ts
The exact generated structure can vary by Vite version and project configuration.
For this lesson, we're interested primarily in:
src/public/configuration
High-Level Structure
For a production-oriented application, think about the project in layers:
React Project│├── Application Source│ └── src/│├── Static Assets│ └── public/│├── Build Configuration│ └── vite.config.ts│├ ── Dependency Configuration│ └── package.json│├── TypeScript Configuration│ └── tsconfig*.json│└── Environment Configuration└── .env*
Then inside src:
src/│├── app/├── features/├── components/├── pages/├── hooks/├── services/├── types/├── utils/└── assets/
This is a scalable starting point, not a mandatory rule.
The src Directory
src contains the application's source code.
A mature application might look like:
src/│├── app/├── features/├── components/├── pages/├── hooks/├── services/├── types/├── utils/├── assets/└── main.tsx
Think of src as:
Business + UI + Application Logic
The app Folder
The app folder can contain application-level configuration and composition.
For example:
src/└── app/├── App.tsx├── routes/├── providers/├── config/└── store/
Typical responsibilities:
app/├── Application bootstrap├── Routing├── Global providers├── Application configuration└── Global state setup
For example:
function App() {return (<AuthProvider><ThemeProvider><RouterProvider /></ThemeProvider></AuthProvider>);}
This is application composition.
The features Folder
For large applications, this is one of the most valuable folders.
Instead of organizing everything by technical type:
components/hooks/services/
you can organize around business capabilities:
features/├── authentication/├── courses/├── learning/├── payments/└── profile/
Each feature can contain its own:
componentshooksservicestypespagestests
For example:
features/└── courses/├── components/├── hooks/├── services/├── types/├── pages/└── tests/
This creates a strong business boundary.
Why Feature-Based Structure?
Imagine you are asked:
Where is the course enrollment logic?
With a feature-based architecture:
features/└── courses/
You immediately know where to look.
Without it:
components/hooks/services/utils/pages/
you may need to search across the entire application.
Feature-based organization provides locality.
Related code stays together.
Example: TechLearningPro
Imagine TechLearningPro has:
features/├── authentication/├── courses/├── learning/├── quizzes/├── certificates/├── payments/└── user-profile/
Now the business domain becomes visible from the folder structure.
TechLearningPro│├── Authentication├── Courses├── Learning├── Quizzes├── Certificates├── Payments└── User Profile
This is more meaningful than:
components/services/hooks/utils/
alone.
Feature Structure Example
Consider:
features/└── courses/│├── components/│ ├── CourseCard.tsx│ ├── CourseList.tsx│ └── CourseProgress.tsx│├── hooks/│ └── useCourses.ts│├── services/│ └── courseService.ts│├── types/│ └── course.types.ts│├── pages/│ ├── CoursesPage.tsx│ └── CourseDetailsPage.tsx│└── tests/
Now everything related to courses is close together.
The components Folder
The shared components folder should generally contain reusable UI components.
For example:
components/├── Button/├── Modal/