Performance: Folder structure best practices
This affects the maintainability and scalability of the codebase, indirectly impacting developer productivity and build performance.
src/
components/
Button/
Button.jsx
Button.css
Header/
Header.jsx
Header.css
utils/
index.js
data/
data.json
App.jsx
index.jssrc/ App.js index.js Button.js Header.js styles.css utils.js data.json
| Pattern | Build Time Impact | Developer Productivity | Code Maintainability | Verdict |
|---|---|---|---|---|
| Flat folder with mixed files | High - many files in one folder slow indexing | Low - hard to find files | Low - confusing structure | [X] Bad |
| Feature-based folder structure | Low - better caching and incremental builds | High - easy to navigate | High - clear separation | [OK] Good |
components, pages, and hooks?components and hooks group related files by their role.components folder.public or node_modules folders, which serve other purposes.components folder -> Option Apublic foldernode_modules foldersrc/
components/
Button.jsx
hooks/
useToggle.js
pages/
Home.jsx
hooks folder.useToggle.js inside hooks matches the custom hook naming pattern.src/
components/
Header.jsx
utils/
helpers.js
Header.jsxHeader.jsx files: one in components and one in root.Header.jsx file in root and components folder causes confusion -> Option BPass the test and this pattern moves unknown