Typical structure
txt
my-react-app/
public/
src/
assets/
components/
pages/
hooks/
services/
context/
store/
utils/
styles/
App.tsx
main.tsxWhat goes where
components/: reusable UI piecespages/: route-level screenshooks/: reusable stateful logicservices/: API clients and external integrationscontext/orstore/: global/shared stateutils/: pure helper functions
Feature-first structure (recommended for larger apps)
txt
src/
features/
auth/
components/
hooks/
services/
authSlice.ts
products/
components/
services/This keeps related code together and scales better.
Naming conventions
- Components:
PascalCase(UserCard.tsx) - Hooks:
camelCasewithuseprefix (useAuth.ts) - Utils/services:
camelCase(apiClient.ts)
Best practices
- Keep components small and focused
- Co-locate tests near source files
- Avoid deep relative imports by using path aliases
Next, we will cover React syntax fundamentals.