name: apply-feature-sliced-design description: Use when a medium-to-large frontend (React, Vue, Angular, Svelte) needs a formal, team-wide architecture standard — features keep importing each other, nobody agrees where code belongs, or onboarding is slow — and simple feature folders are no longer enough. source: 'Feature-Sliced Design, "Feature-Sliced Design Methodology" documentation, feature-sliced.design (v2); Feature-Sliced Design, Steiger linter; Martin, "Clean Architecture" (dependency rule), 2017; Parnas, "On the Criteria To Be Used in Decomposing Systems into Modules", CACM 15(12), 1972' tags: [project-structure, feature-sliced-design, frontend, layered-architecture, team-scaling, conventions] related: [design-frontend-project-structure, apply-module-boundary-enforcement, apply-package-by-feature, design-component]
Apply Feature-Sliced Design
Organize frontend code into standardized layers (app, pages, widgets, features, entities, shared), split by business slices, with technical segments inside each slice. Modules may import only from layers below them and only through each slice's public API.
Why This Is Best Practice
Adopted by:
- An open methodology with official docs and tooling (the Steiger linter, plus ESLint configs).
- Used by product teams across the Russian- and English-speaking frontend communities.
- Framework-agnostic, with official guides for React, Next.js, Vue/Nuxt, and others.
Impact:
- A shared vocabulary and placement rules mean "where does this go?" has one answer, which reduces review debates and speeds onboarding.
- The strict downward-only import rule rules out circular dependencies between business areas by design, and the linter can verify it automatically.
Why best:
- Ad-hoc feature folders work until features need to share business entities, and then they import each other freely.
- FSD separates reusable business entities (user, product) from user features (add-to-cart, login) and composite widgets. This gives each a home and a direction of dependency.
Sources: Feature-Sliced Design documentation (feature-sliced.design). Steiger (github.com/feature-sliced/steiger). Martin, R.C. (2017), Clean Architecture. Parnas (1972).
Steps
Learn the layers, from top to bottom. Each may import only from layers below it:
Layer Holds Example appProviders, router, global styles, entry app/providers,app/routerpagesFull pages or route screens pages/product-detailswidgetsLarge self-contained UI blocks composing features and entities widgets/header,widgets/product-listfeaturesUser interactions that bring business value features/add-to-cart,features/auth-by-emailentitiesBusiness entities and their UI/model entities/user,entities/productsharedGeneric, business-agnostic code shared/ui,shared/api,shared/lib,shared/config(The older
processeslayer is deprecated. Not every project needs every layer.)Split layers into slices by business domain (all layers except
appandshared):entities/product,features/add-to-cart. Slices on the same layer must not import each other.Split slices into segments by technical purpose:
features/add-to-cart/ ui/ # AddToCartButton.tsx model/ # store, hooks, business logic api/ # requests lib/ # slice-local helpers config/ index.ts # public API: the only import entry for other slicesName segments by purpose, not by type (avoid
components/,hooks/,types/as segments).Expose a public API per slice. Other code imports
@/features/add-to-cart, never@/features/add-to-cart/ui/AddToCartButton.Place code with the decision rules:
- Reused business object with its own data and visuals? →
entities. - A user action with business value (verb)? →
features. - Composes several features and entities into a block? →
widgets. - No business knowledge? →
shared. - Used in one place only? Keep it in that slice. Don't pre-emptively lift it.
- Reused business object with its own data and visuals? →
Handle cross-entity references (an order referencing a user) by composing at a higher layer, or use the official
@xcross-import notation for unavoidable entity-to-entity links.Enforce with tooling. Run Steiger (the official FSD linter) or eslint-plugin-boundaries in CI to check layer direction, public-API imports, and same-layer isolation (see
apply-module-boundary-enforcement).Adopt incrementally. Start with
app,pages, andshared, then extractentitiesandfeaturesas you touch code. Migrating everything at once isn't necessary.
Rules
- Import only from layers below, never from the same layer's other slices or from above.
- Import other slices only through their public API (
index.ts). - Segments are named by purpose (
ui,model,api,lib,config). sharedcontains no business logic.- Don't create layers or slices you don't need yet.
Common Mistakes
- Everything becomes a feature. Entities, pages, and widgets are dumped into
features/. Use the decision rules. - Over-slicing small apps. Six layers for ten components is overhead. Use simple feature folders (
design-frontend-project-structure). - Deep imports bypassing public APIs. These defeat the isolation guarantees.
- Type-named segments (
components/,hooks/) inside slices. They lose the purpose-based meaning.
Examples
E-commerce product page:
pages/productcomposeswidgets/product-galleryandwidgets/related-products.features/add-to-cartusesentities/product(its model and types) andentities/cart.shared/ui/Buttonandshared/api/clientare used everywhere.- Steiger runs in CI.
Next.js integration: keep Next's app/ (or pages/) router folder for routing only, re-exporting FSD pages layer components from src/pages (per the official Next.js guide).
When NOT to Use
- Small apps, landing pages, and prototypes, where a flat or simple feature-folder structure is faster.
- Teams unwilling to learn the vocabulary. A half-adopted FSD is worse than consistent simple feature folders.