0

I've built a simple preact app using the default setup with preact cli's preact create. Building my app using preact build, the build folder contains index.html as an entry point/file, meaning my app is built as a stand-alone site.

What I would like to do though is embed my preact app on an existing webpage. This means that I (probably) need my built preact app to have a javascript file as an entry point that would contain something like:

import {render} from 'preact'
import App from './components/app'

render(<App />, document.getElementById('id-of-tag-on-an-existing-webpage'))

How do I achieve that?

artooras
  • 6,315
  • 9
  • 45
  • 78
  • You wouldn't be able to use `preact-cli` to do that, not without extensive (and extremely fragile) configuration changes. Something like [Microbundle](https://github.com/developit/microbundle), which is also from the Preact team, could be an option. You want a library or a widget, not an app, if you're embedding elsewhere. – rschristian May 27 '23 at 22:11

0 Answers0