vercel-composition-patterns

Refactor React component libraries by replacing boolean props with compound components and context providers.

Updated Mar 1, 2026
One-click install
npx skills add https://github.com/sao-coding/sao-blog --skill vercel-composition-patterns-sao-coding
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: vercel-composition-patterns
Source: https://github.com/sao-coding/sao-blog/tree/main/.agents/skills/vercel-composition-patterns
Command: npx skills add https://github.com/sao-coding/sao-blog --skill vercel-composition-patterns-sao-coding

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Avoids boolean prop proliferation by promoting composition through compound components, lifting state, and context-driven APIs. These patterns help keep codebases scalable and maintainable as teams grow.

Core Features & Use Cases

  • Compound components with a shared context to compose internals without prop drilling.
  • Explicit component variants instead of many boolean flags.
  • Provider-based state lifting to share state across UI parts and outside the main frame.

Quick Start

Refactor a React component library by replacing boolean props with explicit variants and a shared composer context.

Frequently Asked Questions about vercel-composition-patterns

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

FAQPage Schema
How do I avoid boolean prop proliferation in my React component library?

You can eliminate boolean prop proliferation by replacing multiple flags with explicit component variants and composing internals through React compound components. This approach scales your UI APIs without deep prop drilling.

What is the best way to share state across React components without prop drilling?

The best way to share state without prop drilling is provider-based state lifting. By moving shared state into a context provider, you can access it across different UI parts outside the main component frame.

How do I manage context in React 19 without using useContext?

React 19 replaces useContext with the use() hook for context-based state management. This modern practice allows you to consume context within your compound components more efficiently.

How do I refactor a large React codebase to use compound components?

To refactor a large React codebase, replace deeply nested boolean props with explicit variants and a shared composer context. This allows you to compose component internals while avoiding forwardRef and prop drilling.

When should I use explicit variants instead of boolean flags in React?

You should use explicit variants instead of boolean flags when your React components scale and require clear API boundaries. This pattern avoids complex conditional rendering and keeps your component library maintainable.

Does React 19 require forwardRef for passing refs through compound components?

No, React 19 practices avoid forwardRef when building compound components. You can pass refs directly as props, simplifying your context-driven APIs and reducing boilerplate.