Web Component - Progressive Enhancement #4327
jake-danton
started this conversation in
Show and tell
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
We recently switched to Preact from Lit and were looking for the same progressive enhancement behavior as
@lit-labs/ssr
provides. So we created preact-progressive-enhancement.With this, we can define a web component that works as expected when run fully on client side but that also prerenders server side while retaining the custom html tags for targeted hydration.
So, given a Preact component:
You define a progressively enhanced web component:
Which you can use during SSR:
And get prerendered html:
Which you can optionally hydrate by importing the file with the
define
call client side.Combining this with the
is-land
component has resulted in an easy DIY island architecture in just a few lines of code and completely compatible with any frameworks.Beta Was this translation helpful? Give feedback.
All reactions