Logo

πŸš€ Production-Ready React Folder Structure πŸ“‚βš›οΈ

A comprehensive guide to structuring React projects for scalability, maintainability, and team collaboration. Includes a real-world folder structure example.

Salman Khan

6/9/2024 Β· 3 min read

Production-Ready React Folder Structure

Building scalable, maintainable, and efficient React applications starts with a strong foundation β€” and that foundation is project structure.

Here’s a practical and battle-tested folder structure for React projects, designed for real-world applications:

βœ… Modular and Feature-Based Architecture
βœ… Organized Components, Hooks, Services, and Types
βœ… Clear Separation of Concerns
βœ… Support for Scalability and Team Collaboration
βœ… Maintainable Codebase for Enterprise-Grade Applications


🧩 Key Highlights

  • πŸ“ components/ β€” Common reusable UI components like Button, Modal, Layouts (MainLayout, AuthLayout).
  • πŸ“ features/ β€” Feature-specific modules (e.g., products, users) with their own components, hooks, services, and types, isolated by domain.
  • πŸ“ hooks/ β€” Reusable custom hooks (e.g., useAuth, useDebounce) at a global level.
  • πŸ“ routes/ β€” Centralized route management with protected routes and app-wide routing configuration.
  • πŸ“ services/ β€” API services, interceptors, and network utilities.
  • πŸ“ store/ β€” Centralized state management (Redux slices, store configuration).
  • πŸ“ utils/ β€” Helper functions and constants for clean and DRY code.
  • πŸ“ styles/ β€” Global SCSS styling including variables, mixins, and global styles.
  • πŸ“ assets/ β€” Static assets like images, fonts, and icons.
  • πŸ“ pages/ β€” Top-level route pages (HomePage, LoginPage, ProductPage) composed of features and components.
  • πŸ“ tests/ β€” Organized tests for components, pages, and utilities.

πŸ”§ Why it matters?

βœ… Enhances team productivity and onboarding
βœ… Supports modular growth and scaling
βœ… Reduces technical debt over time
βœ… Improves code readability, reusability, and maintainability

πŸ’¬ How do you structure your React projects for scalability and maintainability? Would love to hear your approaches!

#ReactJS #Redux #FrontendDevelopment #ProductionReady #BestPractices #WebDevelopment #SoftwareArchitecture #CleanCode #DeveloperCommunity

src/
β”œβ”€β”€ components/
β”‚   β”œβ”€β”€ common/
β”‚   β”‚   β”œβ”€β”€ Button/
β”‚   β”‚   β”‚   β”œβ”€β”€ Button.tsx
β”‚   β”‚   β”‚   β”œβ”€β”€ Button.module.scss
β”‚   β”‚   β”‚   └── index.ts
β”‚   β”‚   β”œβ”€β”€ Modal/
β”‚   β”‚   β”‚   β”œβ”€β”€ Modal.tsx
β”‚   β”‚   β”‚   β”œβ”€β”€ Modal.module.scss
β”‚   β”‚   β”‚   └── index.ts
β”‚   β”‚   β”œβ”€β”€ layouts/
β”‚   β”‚   β”‚   β”œβ”€β”€ MainLayout/
β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ MainLayout.tsx
β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ MainLayout.module.scss
β”‚   β”‚   β”‚   β”‚   └── index.ts
β”‚   β”‚   β”‚   β”œβ”€β”€ AuthLayout/
β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ AuthLayout.tsx
β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ AuthLayout.module.scss
β”‚   β”‚   β”‚   β”‚   └── index.ts
β”‚   β”œβ”€β”€ features/
β”‚   β”‚   β”œβ”€β”€ products/
β”‚   β”‚   β”‚   β”œβ”€β”€ components/
β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ ProductList/
β”‚   β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ ProductList.tsx
β”‚   β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ ProductList.module.scss
β”‚   β”‚   β”‚   β”‚   β”‚   └── index.ts
β”‚   β”‚   β”œβ”€β”€ hooks/
β”‚   β”‚   β”‚   └── useProducts.ts
β”‚   β”‚   β”œβ”€β”€ services/
β”‚   β”‚   β”‚   └── productService.ts
β”‚   β”‚   β”œβ”€β”€ types/
β”‚   β”‚   β”‚   └── product.ts
β”‚   β”œβ”€β”€ users/
β”‚   β”‚   β”œβ”€β”€ components/
β”‚   β”‚   β”‚   β”œβ”€β”€ UserProfile/
β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ UserProfile.tsx
β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ UserProfile.module.scss
β”‚   β”‚   β”‚   β”‚   └── index.ts
β”‚   β”‚   β”œβ”€β”€ hooks/
β”‚   β”‚   β”‚   └── useUser.ts
β”‚   β”‚   β”œβ”€β”€ services/
β”‚   β”‚   β”‚   └── userService.ts
β”‚   β”‚   β”œβ”€β”€ types/
β”‚   β”‚   β”‚   └── user.ts
β”œβ”€β”€ hooks/
β”‚   β”œβ”€β”€ useAuth.ts
β”‚   β”œβ”€β”€ useDebounce.ts
β”‚   └── index.ts
β”œβ”€β”€ routes/
β”‚   β”œβ”€β”€ AppRoutes.tsx
β”‚   β”œβ”€β”€ ProtectedRoute.tsx
β”‚   └── index.ts
β”œβ”€β”€ services/
β”‚   β”œβ”€β”€ apiClient.ts
β”‚   └── errorHandler.ts
β”œβ”€β”€ store/
β”‚   β”œβ”€β”€ slices/
β”‚   β”‚   β”œβ”€β”€ authSlice.ts
β”‚   β”‚   β”œβ”€β”€ productSlice.ts
β”‚   β”‚   └── index.ts
β”‚   β”œβ”€β”€ hooks.ts
β”‚   └── store.ts
β”œβ”€β”€ utils/
β”‚   β”œβ”€β”€ constants.ts
β”‚   β”œβ”€β”€ formatters.ts
β”‚   └── helpers.ts
β”œβ”€β”€ styles/
β”‚   β”œβ”€β”€ variables.scss
β”‚   β”œβ”€β”€ global.scss
β”‚   └── mixins.scss
β”œβ”€β”€ assets/
β”‚   β”œβ”€β”€ images/
β”‚   β”œβ”€β”€ icons/
β”‚   └── fonts/
β”œβ”€β”€ pages/
β”‚   β”œβ”€β”€ HomePage.tsx
β”‚   β”œβ”€β”€ LoginPage.tsx
β”‚   └── ProductPage.tsx
β”œβ”€β”€ tests/
β”‚   β”œβ”€β”€ components/
β”‚   β”œβ”€β”€ pages/
β”‚   └── utils/
β”œβ”€β”€ App.tsx
β”œβ”€β”€ main.tsx
└── index.html