Next.js Architecture (FSD)

Organizes Next.js applications into Feature-Sliced Design layers with defined import rules.

51|6|Updated Mar 28, 2019
One-click install
npx skills add https://github.com/Mte90/dotfiles --skill next-js-architecture-fsd
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: Next.js Architecture (FSD)
Source: https://github.com/Mte90/dotfiles/tree/main/.config/opencode/skills/nextjs/architecture
Command: npx skills add https://github.com/Mte90/dotfiles --skill next-js-architecture-fsd

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill addresses the challenge of maintaining large, complex Next.js applications by providing a structured and scalable folder organization system based on Feature-Sliced Design (FSD).

Core Features & Use Cases

  • Scalable Folder Structure: Organizes code by business domain (features, entities) rather than file type, promoting maintainability.
  • Layered Architecture: Enforces clear import rules between layers (App, Widgets, Features, Entities, Shared) to prevent spaghetti code.
  • Next.js Integration: Provides guidance on integrating FSD principles with Next.js App Router features like Server Components, Server Actions, and Edge Runtime.
  • Use Case: When starting a new Next.js project expected to grow significantly, use this Skill to establish a robust architecture that will support future development and team collaboration.

Quick Start

Adopt Feature-Sliced Design for your Next.js project by organizing your source code according to the specified layer hierarchy and segment naming conventions.

Frequently Asked Questions about Next.js Architecture (FSD)

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I structure a large Next.js application for scalability?

To structure a scalable Next.js application, implement Feature-Sliced Design (FSD) by organizing code into layers like App, Widgets, Features, Entities, and Shared, preventing spaghetti code through defined import rules.

What is the best way to organize Next.js App Router folders by business domain?

Organizing Next.js App Router folders by business domain involves using Feature-Sliced Design to group code into slices with standard segments like ui, model, api, lib, and config, ensuring maintainability as the project grows.

Can I use Feature-Sliced Design with Next.js Server Components and Server Actions?

Yes, Feature-Sliced Design integrates with Next.js App Router features, providing specific guidance on combining FSD principles with Server Components, Server Actions, and runtime selection for Node.js or Edge environments.

How do FSD import rules prevent spaghetti code in Next.js projects?

FSD prevents spaghetti code in Next.js by enforcing strict layered architecture import rules between App, Widgets, Features, Entities, and Shared layers, ensuring dependencies flow in one direction and maintaining clear boundaries.

When should I adopt Feature-Sliced Design in my Next.js project?

Adopt Feature-Sliced Design when starting a new Next.js project expected to grow significantly, establishing a robust architecture that supports future development and team collaboration through structured folder organization.

What are the standard segment names within slices in a Next.js FSD architecture?

In a Next.js FSD architecture, standard segment names within slices include ui, model, api, lib, and config, organizing code consistently across different business domains to promote maintainability.