The src Folder Convention
What you'll learn: Why React projects separate application code in src/ from configuration files at the root.
The Separation Pattern
When you create a React project with Vite (or any modern tooling), you'll notice two distinct areas:
Root level contains tooling configuration:
vite.config.js(build setup)package.json(dependencies).gitignore(version control)index.html(entry point)
Inside src/ lives your actual application:
main.jsx(React bootstrap)- Components
- Styles
- Images and assets you import
Why This Separation Exists
Think of your project like a restaurant: the dining room (root) has menus and signage that guests see, while the kitchen (src/) contains all the actual cooking equipment and ingredients. You wouldn't store recipe ingredients next to the front door.
The src/ folder convention serves three purposes:
- Clear boundaries: Configuration stays separate from application logic
- Build optimization: Tools know to process only
src/contents during development - Import resolution: Modern bundlers treat
src/as the starting point for module imports
What Goes Where
Root level (outside src/):
- Files that control how your project builds and runs
- Public assets served directly without processing
Inside src/:
- Files that are your React application
- Code that gets transformed/bundled
- Assets imported into components
This isn't just convention—build tools like Vite specifically watch src/ for Hot Module Replacement, and production builds start at src/main.jsx to create your optimized bundle.
Key Takeaway: The src/ folder contains your React application code, while the root holds configuration files—this separation keeps concerns distinct and helps build tools work efficiently.