The problem with "just start coding" Small React projects are forgiving. At a hundred components, a flat folder becomes a maze.\
Here is a battle-tested folder structure tailored for large-scale React applications, designed to keep your codebase clean, modular, and easy to navigate as your team and component count grow.
The Feature-Based Structure
Instead of grouping files by their technical type (e.g., keeping all components in one folder, all hooks in another), group them by domain feature. This keeps related code close together and makes deleting or refactoring features incredibly simple.
src/
├── assets/ # Global static files (images, icons, fonts)
├── components/ # Shared, global UI components (Button, Input, Modal)
├── config/ # Global configurations, environment variables
├── context/ # Global React contexts (Theme, Auth)
├── features/ # The core of your app, split by domain/module
│ ├── auth/ # Feature: Authentication
│ │ ├── components/ # Auth-specific components (LoginForm)
│ │ ├── hooks/ # Auth-specific custom hooks (useAuthMutation)
│ │ ├── types/ # TypeScript interfaces for auth
│ │ └── index.ts # Public API for the auth feature
│ ├── dashboard/ # Feature: Dashboard Metrics
│ └── users/ # Feature: User Profiles & Management
├── hooks/ # Shared global custom hooks (useDebounce, useLocalStorage)
├── layouts/ # Shared page layouts (SidebarLayout, AuthLayout)
├── lib/ # Configurations for third-party libraries (axios, supabase)
├── providers/ # Global application providers (QueryClientProvider, ThemeProvider)
├── routes/ # Routing configuration and page definitions
├── services/ # Global API services / SDK integrations
├── utils/ # Global helper functions (formatDate, currencyFormatter)
└── main.tsx # Application entry point
Key Principles for Scalability
-
The
featuresFolder is King: Everything specific to a single business capability lives inside its respective feature folder. If a component is only used in the dashboard, it stays insidefeatures/dashboard/components. -
Enforce a "Public API" (
index.ts): Each feature folder should export anindex.tsfile that acts as its gatekeeper. Other parts of the app should only import from this index file, masking the internal file structure of that feature. -
Strict Common/Shared Rules: The global
components/folder is reserved strictly for generic, reusable UI elements (like Design System tokens or shadcn primitives). If a component contains business logic, it belongs in a feature folder.
