vercel-composition-patterns

Design scalable React 19 component libraries using compound components and provider-based state management to reduce boolean props.

53|33|Updated Sep 15, 2022
One-click install
npx skills add https://github.com/tutur3u/platform --skill vercel-composition-patterns-tutur3u
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: vercel-composition-patterns
Source: https://github.com/tutur3u/platform/tree/main/.agents/skills/vercel-composition-patterns
Command: npx skills add https://github.com/tutur3u/platform --skill vercel-composition-patterns-tutur3u

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

React composition patterns solve the challenge of scaling React codebases by reducing boolean prop proliferation and enabling reusable APIs through composition and context.

Core Features & Use Cases

  • Explicit component variants: create dedicated variant components (e.g., ThreadComposer, EditMessageComposer) to avoid bloated boolean props.
  • Compound components with shared context: design components that share state via a provider, enabling flexible assembly without prop drilling.
  • State-management patterns: lift state into providers, define a generic context interface, and decouple UI from state implementation.
  • Use cases include refactoring large UI libraries, building design systems, and implementing render-props and context-based APIs.

Quick Start

Start by wrapping a basic Composer.Frame with Composer.Input and Composer.Submit inside a provider, then add additional pieces as needed to demonstrate composition.

Frequently Asked Questions about vercel-composition-patterns

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

FAQPage Schema
How do I reduce boolean prop proliferation in a React component library?

Reduce boolean prop proliferation in a React component library by creating explicit variant components and applying composition patterns. This approach replaces bloated conditional props with dedicated components like ThreadComposer, enabling cleaner and more maintainable UI architecture.

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

Share state across compound components in React by lifting state into a context provider. This defines a generic context interface that decouples UI from state implementation, allowing flexible component assembly without prop drilling.

How do I design generic context interfaces for React 19 APIs?

Design generic context interfaces for React 19 APIs by lifting state management into providers and decoupling the UI from the state implementation. This satisfies explicit variants and ensures compatibility with modern React composition patterns.

Does this composition pattern approach work for refactoring large UI libraries?

This composition pattern approach works effectively for refactoring large UI libraries and building design systems. It implements render-props and context-based APIs to scale React codebases by enabling flexible assembly through providers.

When should I avoid using render props and context providers in React?

Avoid using render props and context providers when simpler component structures suffice without prop drilling. If your UI does not require flexible assembly or shared state across compound components, composition patterns may introduce unnecessary complexity.