Feature-Sliced Design (FSD) architectural methodology for frontend applications...
Front-end μ ν리μΌμ΄μ μ½λλ₯Ό ꡬ쑰ννκΈ° μν μν€ν μ² λ°©λ²λ‘ μΌλ‘, λΉμ¦λμ€ μꡬμ¬ν λ³νμ κ°νκ³ κΈ°λ₯ μΆκ°κ° μ©μ΄ν νλ‘μ νΈ κ΅¬μ‘°λ₯Ό μ 곡ν©λλ€.
Reference these guidelines when:
| Layer | Purpose | Examples |
|---|---|---|
app |
Application initialization | routing, global styles, providers |
pages |
Route-based page components | /home, /profile, /settings |
widgets |
Large independent UI blocks | Header, Sidebar, Dashboard |
features |
Business value features | AddToCart, UserAuth, CommentForm |
entities |
Business entities | User, Product, Order |
shared |
Reusable utilities | UI kit, helpers, types |
Critical Rule: Upper layers can import from lower layers, but NOT vice versa.
app β pages β widgets β features β entities β shared
(Top) (Bottom)
Within each layer, code is separated by business domain:
features/auth/, features/cart/, features/payment/entities/user/, entities/product/, entities/order/Critical Rule: Slices in the same layer CANNOT import from each other.
Within each slice, code is organized by purpose:
| Segment | Purpose |
|---|---|
ui |
React components, styles |
api |
Backend communication, data fetching |
model |
State management, types, business logic |
lib |
Utility functions |
config |
Configuration, feature flags |
Each slice exports through index.ts:
// features/auth/index.ts
export { LoginForm } from './ui/LoginForm';
export { useAuth } from './model/useAuth';
export type { User } from './model/types';
Rule: Only import from Public API, never from internal files directly.
pages can import from widgets, features, entities, sharedfeatures can import from entities, sharedentities CANNOT import from featuresshared CANNOT import from any other layerfeatures/auth β entities/user)features/auth β features/cart)from '@/features/auth'from '@/features/auth/ui/LoginForm'feature/auth/
βββ ui/ # React components
β βββ LoginForm.tsx
βββ api/ # API calls
β βββ authApi.ts
βββ model/ # State & types
β βββ useAuth.ts
β βββ types.ts
βββ lib/ # Utilities
β βββ validation.ts
βββ index.ts # Public API
project/
βββ app/ # Next.js routing (file-system based)
β βββ layout.tsx # Root layout
β βββ page.tsx # Re-export from @/pages/home
β βββ users/
β βββ page.tsx # Re-export from @/pages/users
β
βββ src/ # FSD Architecture
βββ app/ # FSD app layer (providers, init)
β βββ providers/
βββ pages/ # FSD pages layer (page components)
β βββ home/
β β βββ ui/HomePage.tsx
β βββ users/
β βββ ui/UsersPage.tsx
βββ widgets/
βββ features/
βββ entities/
βββ shared/
Key Rules:
app/ folder: routing only, re-export from FSD pagessrc/app/: providers, initializationsrc/pages/: actual page components with business logic'use client' when needed