Course contentsShow
← React
Lesson 208 of 2,3966. Component BasicsFree lesson

Folder Structure: Feature-Based vs Type-Based

Compare organizing by feature (/features/auth/LoginForm.jsx) versus by type (/components/forms/LoginForm.jsx) and when each approach scales.

Folder Structure: Feature-Based vs Type-Based

You'll learn the two main strategies for organizing your React files and when each approach makes sense.

The Two Approaches

As your React app grows, you need a strategy for organizing your components. There are two dominant philosophies:

Type-Based Structure groups files by what they are (their technical type):

/src
  /components
    LoginForm.jsx
    UserProfile.jsx
    Button.jsx
  /hooks
    useAuth.js
  /utils
    validation.js

Feature-Based Structure groups files by what feature they belong to:

/src
  /features
    /auth
      LoginForm.jsx
      useAuth.js
      validation.js
    /profile
      UserProfile.jsx
  /components  // shared components only
    Button.jsx

When to Use Each

Type-based works well when your app is small (under ~10 components). Everything is easy to find because there aren't many files yet. It's simple and familiar if you're just learning.

Feature-based scales better as apps grow. When you have 50+ components, finding "all the authentication-related stuff" is much easier when it's in one /features/auth folder rather than scattered across /components, /hooks, and /utils.

The Kitchen Analogy

Type-based is like organizing your kitchen by item type: all plates together, all utensils together. Feature-based is like organizing meal prep stations: everything for breakfast in one area, everything for baking in another. Small kitchen? Type works fine. Restaurant kitchen? You need stations.

Key Takeaway: Start with type-based for simple apps, but plan to migrate to feature-based organization once you have more than 10-15 components or multiple developers working on different features.