Skip to content

preact-custom-element

Wrap Preact components as standards-based custom elements.

Native PreactActive

Native Preact

Built for Preact and does not require a React compatibility layer.

Packagepreact-custom-element

Facts at a glance
Preact compatibility
Native Preact
Tested Preact versions
Not documented
TypeScript
Native TypeScript
SSR
SSR unsupported
Maintenance
Active
License
MIT
Last verified
Not yet verified
Terminal
npm install preact-custom-element
Preact example
import register from "preact-custom-element";import { Widget } from "./Widget"; register(Widget, "ph-widget", ["title"]);

Introduction

This package is useful when Preact components need to be embedded into non-Preact pages or CMS fragments.

Preact configuration

Register your component with a tag name and optional observed attributes.

SSR notes

Custom elements are usually enhanced on the client.

Islands notes

A good bridge when interactive islands need to be dropped into heterogeneous frontends.

Alternatives