
Description
preact-custom-element is a small library that wraps a Preact component as a custom element, which is the browser's standard way to define a reusable HTML tag. You give it a Preact component and it generates and registers the custom element, so the component can be used in plain HTML and anywhere custom elements are supported. The README has sections on how observed attributes are passed to the component, how slots can be passed through as props, and how static properties are set on the generated element. It is aimed at Preact developers who want to publish a component that works outside a Preact app, for example a widget that other pages embed. The project is hosted on GitHub under the preactjs organization, and the repository includes a code of conduct for contributors. The page shows the library's documentation and usage examples, and it does not list any pricing or hosted service.…
Highlights
- Wraps a Preact component as a custom element
- Observed attributes passed to the component
- Slots passed through as props
- Static properties on the generated element
Ratings & Reviews
No ratings yet
Be the first to rate preact-custom-element.
People also visit

custom-element-vs-code-integration
Tools for integrating web components/custom elements into VS Code
How to use Web Components in React
A tutorial on how to use Web Components in React
@vscode-elements/elements
Web components for creating Visual Studio Code extensions
preact-custom-element FAQ
What is preact-custom-element?
A library that turns a Preact component into a custom element, a reusable HTML tag registered in the browser.
Who is it for?
Developers who use Preact and want to publish a component as a custom element that other pages can use.
How are attributes handled?
The README has a section on observed attributes that explains how HTML attributes are passed to the component.
Is it open source?
Yes. The code is public on GitHub in the preactjs organization.
What are the best preact-custom-element alternatives?
Popular alternatives to preact-custom-element include @webcomponents/custom-elements, custom-element-vs-code-integration and How to use Web Components in React. See all preact-custom-element alternatives














