vercel-composition-patterns
Installation
SKILL.md
React & Next.js Composition Patterns
Composition patterns for building flexible, maintainable React components, tailored for Vercel/Next.js architectures. Avoid boolean prop proliferation by using compound components, lifting state, and composing internals.
Purpose
These patterns ensure components scale easily without turning into massive, unmaintainable monoliths filled with if/else logic based on dozens of boolean props. It makes the codebase easier for both humans and AI agents to work with.
When to Use
- Refactoring UI components with many boolean props (
isLarge,hasIcon,primary). - Building reusable component libraries (e.g., using HeroUI or Radix).
- Designing flexible API boundaries between React Server Components (RSC) and Client Components.
- Working with Context Providers or compound components.
Core Architectural Rules
1. Avoid Boolean Prop Proliferation (HIGH)
Why: Adding a boolean flag for every new feature creates exponential complexity combinations.
Rule: Don't add boolean props (e.g., hasHeader, showFooter) to customize structural behavior. Use composition (children) instead.