react

Integrate custom web components in React 18 and 19 with wrappers and TypeScript typings.

46|4|Updated May 27, 2025
One-click install
npx skills add https://github.com/bennypowers/cem --skill react-bennypowers
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: react
Source: https://github.com/bennypowers/cem/tree/main/extensions/claude-code/skills/react
Command: npx skills add https://github.com/bennypowers/cem --skill react-bennypowers

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This guidance helps developers integrate custom elements into React projects, addressing differences between React 18 and React 19 and providing strategies for wrappers, typings, and slot usage.

Core Features & Use Cases

  • Framework-aware integration for React 18 and 19, covering properties, events, and wrappers.
  • TypeScript typings guidance to ensure correct JSX attributes and element usage across versions.
  • Slot and wrapper guidance for mapping web component slots to React children and wrappers like @lit/react.
  • Use case examples illustrating direct usage, wrappers, and ref-based approaches in real projects.

Quick Start

Detect your project’s React version and follow the guidance for React 19+ native support or React 18 wrappers to start integrating the element.

Frequently Asked Questions about react

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

FAQPage Schema
How do I use custom elements in React 19?

Using custom elements in React 19 relies on native framework support for properties and events, allowing direct integration without wrappers. You can render the elements directly in JSX while passing complex data as props.

What is the best way to integrate web components in React 18?

Integrating web components in React 18 requires wrapper strategies like @lit/react or ref-based approaches to handle properties and events. This bridges the gap until native support arrives in version 19.

How do I add TypeScript typings for custom elements in JSX?

Adding TypeScript typings for custom elements in JSX requires declaring the element interfaces and updating the JSX namespace. This ensures correct attribute typing and type safety across your React project.

How do I map web component slots to React children?

Mapping web component slots to React children involves using wrapper strategies to translate slot attributes into child components. This ensures proper content projection within the custom element.

Do I need a wrapper for custom elements in React?

Wrappers for custom elements in React are necessary for version 18 to handle events and complex properties, but optional in version 19 due to native support. Use @lit/react for simplified integration.

Does React 18 support custom element properties and events natively?

React 18 does not support custom element properties and events natively, requiring wrappers or refs to manage interactions. Version 19 introduces native support, eliminating this limitation.