Course contentsShow
← React
Lesson 60 of 2,3962. Setup and Modern ToolingFree lesson

Feature-Based vs Layer-Based Organization

Learn the difference between grouping by feature (all dashboard files together) vs layer (all components, all hooks, etc.).

Feature-Based vs Layer-Based Organization

What you'll learn: Two competing philosophies for organizing your React project files—by what they do (feature) or what they are (layer).

The Core Distinction

When organizing your React codebase, you face a fundamental choice: group files by feature (grouping everything related to a specific part of your app together) or by layer (grouping all similar types of files together).

Layer-Based Organization (Technical Grouping)

Think of this like organizing a toolbox by tool type—all hammers together, all screwdrivers together:

src/
  components/
    DashboardChart.jsx
    DashboardFilters.jsx
    UserProfile.jsx
    UserSettings.jsx
  hooks/
    useDashboardData.js
    useUserData.js
  styles/
    dashboard.css
    user.css

Pros: Easy to find "all components" or "all hooks"
Cons: Related functionality is scattered across folders

Feature-Based Organization (Domain Grouping)

This is like organizing a kitchen by meal type—breakfast items together, baking supplies together:

src/
  dashboard/
    DashboardChart.jsx
    DashboardFilters.jsx
    useDashboardData.js
    dashboard.css
  user/
    UserProfile.jsx
    UserSettings.jsx
    useUserData.js
    user.css

Pros: Everything for one feature lives together, easier to modify or delete features
Cons: Harder to enforce consistency across similar file types

Which Should You Choose?

For small projects, either works. As apps grow, feature-based typically scales better because changes usually happen within a single feature, not across all components.

Key Takeaway: Layer-based groups by what files are (components, hooks), while feature-based groups by what they accomplish (dashboard, user management). Feature-based typically wins for larger applications.