Common Top-Level Folders: hooks, utils, types
What you'll learn: How to organize reusable code that doesn't belong to a single feature by creating standard directories at the top level of your project.
The "Shared Code" Problem
As your React app grows beyond a single feature, you'll write code that multiple components need: custom hooks for common logic, utility functions for data formatting, and TypeScript type definitions. Without a clear home for these, developers scatter them randomly or duplicate them across features.
The Standard Solution
Create three dedicated folders directly inside src/:
/hooks
Custom hooks that multiple features use. Think useAuth, useDebounce, or useLocalStorage. These encapsulate reusable stateful logic that isn't tied to one feature.
/utils
Pure functions with no React-specific behavior. Date formatters, validators, API helpers, string manipulators—anything that could theoretically work outside React. Like a toolbox of general-purpose helpers.
/types
TypeScript type definitions and interfaces shared across features. User shapes, API response types, shared enums. This only appears if you're using TypeScript.
When to Use Each
Hooks folder: If it uses useState, useEffect, or other hooks and is needed by 2+ features.
Utils folder: If it's a plain function doing calculations, transformations, or formatting.
Types folder: If it's a TypeScript definition used in multiple places.
If something is only used by one feature, keep it colocated with that feature instead.
Key Takeaway: Top-level hooks, utils, and types folders give reusable code a predictable home, preventing duplication and making your codebase easier to navigate as it scales beyond simple feature boundaries.