DEV Community

Cover image for Recommended Folder Structure for React 2025

Recommended Folder Structure for React 2025

Pramod Boda on February 21, 2025

For a React project in 2025, a well-organized folder structure is essential for maintainability, scalability, and ease of collaboration. The struct...
Collapse
 
himanshu_code profile image
Himanshu Sorathiya

How can this be 100% same like mine, I also prefer this same layout, one thing diff is that I prefer store related slices in their own feature related folder, like authSlice will go in Auth folder.
Great and best folder structure you'll ever see which lists out all aspects with proper example

Collapse
 
pramod_boda profile image
Pramod Boda

Thank you for your feedback! I completely agree with organizing slices into their feature-related folders—it’s a great approach for maintaining scalability and readability. The structure I shared is just one way to do it, and your method of placing authSlice in an Auth folder makes a lot of sense, especially for larger projects. It’s all about finding what works best for the team and the project’s needs. Thanks for sharing your perspective!

Collapse
 
agws profile image
And Go Web Solutions | AGWS

Yes this is a great project structure i used a similar one a couple of times , i would just mention that the context api in the comment is not a a state management like redux ,Context is a form of Dependency Injection that you can handle its state using useReducer, ive tested it out myself and as your project gets bigger its gets worse to handle state management it gets very slow.

Collapse
 
jack_hurry_05395429b71e88 profile image
Jack Hurry

A well-structured React project ensures better maintainability and scalability! The feature-based approach is a great way to keep things modular. If you're managing workplace applications, having a secure access system is just as important. Check out Online health management for more insights on optimizing secure access and user management. 🚀

Collapse
 
hombre2014 profile image
Yuriy Chamkoriyski

OK, I have a question about tests folder? Where is it? I have heard that there are two main concepts about it - put all the test files in test or __test__ folder or just have all the .test files src collocated in the folder. Any comments about that?

Collapse
 
nqhed profile image
Huy Edward Nguyen

The article is very good, the project structure is very simple and easy to maintain.

Collapse
 
pramod_boda profile image
Pramod Boda

Thank you 😊

Collapse
 
bademiya_sk_7879589c1129a profile image
Bademiya Sk

Thank you so much for sharing this kind of knowledge it is very easy to understand and use....

Collapse
 
llxd profile image
Lucas Lima do Nascimento

Hey @pramod_boda! Awesome article!

I'm currently working on an open-source project to help people organize and structure their React apps! I'd love for you to take a look and share insights -- or even contribute to it with your structure, if you're feeling into it!

Rorg - React Organizer

Collapse
 
michaelandish profile image
Michael

The folder structure is neat and clean, thank you! I'm particularly interested in how feature-nested folders will be organized. Are they designed to be independent modules? Also, how will we configure ESLint to prevent unintended feature dependencies?

I found this video [dly.to/9XmRt2U39uO] helpful and thought you might too.

By the way, here's the squad you can join [app.daily.dev/squads/weprodev].

Thanks for sharing!

Collapse
 
lord007tn profile image
Raed Bahri

tbh a module based or feature based structure should be extended to support more the scalability and the organization
you can supercharge it with a eslint rule where you can import from feature to feature for better isolation
mention to people that every folder outside the feature can be repeated under the feature

Collapse
 
kleninb profile image
Prathap Karumanchi

ChatGTP suggested this structure.

/my-react-app
│── 📂 src
│ ├── 📂 app
│ │ ├── 📂 routes # All application routes
│ │ ├── 📂 layout # Layout components (Header, Footer, etc.)
│ │ ├── 📂 hooks # Custom hooks
│ │ ├── 📂 providers # Context API Providers
│ │ ├── 📂 services # API calls (GraphQL/REST)
│ │ ├── 📂 store # Global state management (Redux, Zustand, Jotai, etc.)
│ │ ├── 📂 types # Global TypeScript types
│ │ ├── 📂 utils # Utility/helper functions
│ │ ├── 📂 config # Configuration & environment setup
│ ├── 📂 components
│ │ ├── 📂 ui # Reusable UI components (buttons, modals, forms)
│ │ ├── 📂 features # Feature-specific components
│ │ ├── 📂 animations # Animation files (Framer Motion, GSAP)
│ ├── 📂 modules
│ │ ├── 📂 auth # Authentication logic
│ │ ├── 📂 dashboard # Dashboard-related logic
│ │ ├── 📂 profile # User profile logic
│ ├── 📂 assets # Static assets (images, fonts, icons)
│ ├── 📂 styles # Global styles (Tailwind, SCSS, CSS Modules)
│ ├── 📂 tests # Unit & integration tests (Jest, React Testing Library)
│ ├── 📂 mocks # Mock data for tests
│ ├── main.tsx # Application entry point
│ ├── App.tsx # Main App component
│ ├── router.tsx # React Router setup
│── 📂 public # Static files (favicon, index.html)
│── .env # Environment variables
│── tsconfig.json # TypeScript configuration
│── package.json # Dependencies and scripts
│── README.md # Documentation

Collapse
 
jason_perry_e949878aa5725 profile image
Jason Perry

Remove the two testing-related folders (tests and mocks) and that's no different than what OP is suggesting. The app folder isn't necessary, since that's what 'src' is and 'features' has simply been renamed 'modules' here... Personally, I prefer 'features' and that's usually what I see this folder named.

Collapse
 
zeroinfinity profile image
Atilla

I am sorry, but I see this everywhere. Why would you have a folder called "features". I don't understand. The term "Feature" is actually used in Scrum and PMs. It is not and should not be part of your code. It should be defined by Entities. Most likely you work with "Entities" not feature you suppose to be implementing.

Collapse
 
balis_baliev_09ac74f9ef1a profile image
Balis Baliev

You need to find out FSD architectural methodology

Collapse
 
56_kode profile image
56kode

It's good, but I always prefer to add a subfolder in components. For example, something like components/button/Button.tsx is useful because you can include tests, Storybook files, subcomponents, and more.

Collapse
 
essijunior profile image
NDANG ESSI Pierre Junior

Thanks bro

Collapse
 
fernandomenuk profile image
Menuk Fernando

niceeeee

Collapse
 
palette profile image
Palette

Good!