Skip to content

How can you use Preact components inside of a React project? #4236

Discussion options

You must be logged in to vote

That blog post from 2018 about the different JSX factories is outdated. Since we launched Preact 10.x in 2019 Preact ships with both the h() and createElement() factory out of the box. The main difference when authoring component libraries for React or Preact are the imports. For React you'll be importing from react and for Preact that will be preact or preact/hooks. Most folks who dual publish for React and Preact publish separate npm packages where the imports are rewritten accordingly. That's pretty much all there is to it.

Replies: 1 comment 5 replies

Comment options

You must be logged in to vote
5 replies
@adamzerner
Comment options

@rschristian
Comment options

@adamzerner
Comment options

@adamzerner
Comment options

@marvinhagemeister
Comment options

Answer selected by adamzerner
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants