vercel-composition-patterns
React composition patterns that scale. Use when refactoring components with boolean prop proliferation, building flexible component libraries, or designing reusable APIs. Triggers on tasks involving compound components, render props, context providers, or component architecture. Includes React 19 API changes.
Install
npx skills add https://github.com/vercel-labs/agent-skills --skill vercel-composition-patterns- title
- Lift State into Provider Components
- impact
- HIGH
- impactDescription
- enables state sharing outside component boundaries
- tags
- composition, state, context, providers
Lift State into Provider Components
Move state management into dedicated provider components. This allows sibling components outside the main UI to access and modify state without prop drilling or awkward refs.
Incorrect (state trapped inside component):
Incorrect (useEffect to sync state up):
Incorrect (reading state from ref on submit):
Correct (state lifted to provider):
The ForwardButton lives outside the Composer.Frame but still has access to the submit action because it's within the provider. Even though it's a one-off component, it can still access the composer's state and actions from outside the UI itself.
Key insight: Components that need shared state don't have to be visually nested inside each other—they just need to be within the same provider.