Open ceIia opened 10 months ago
Thanks for trying this out!
I tried WeSC in the past with the Shoelace UI components which are also created w/ Lit and it had some issues as well. If I remember correctly Lit is using some advanced DOM API's which are not supported by Linkedom which WeSC uses for polyfilling the DOM.
It is probably possible to achieve but it might take some time and more support from other devs. (If you put your code online somewhere, I'm happy to take a quick look but can't promise anything)
Just curious, doesn't Lit offer an SSR implementation? I think that's probably the way to go because it bypasses many DOM API's using its template syntax.
cc'ing @justinfagnani
ah! i understand. thanks for the lightning fast answer by the way.
lit does indeed have ssr implementations through @lit-labs/nextjs, @lit-labs/ssr-react and some other packages. sadly, there is no support for app router yet, and it seems some more issues have been piling up on top because of next@14 → https://github.com/lit/lit/issues/3657. i know they're quite backed up at the moment with lit 3.0, so I went looking for some other alternatives, and found your repository in a comment on GH & reddit 😄
i am trying to make a reproduction repository, but i'm running into different issues with hydration mismatches and such 🥲 although in the meantime here's a next@14 basic component setup (w/o WeSC for now): https://github.com/ceIia/lit-next-ssr/tree/next-14
hey!
i tried implementing wesc in a next.js project running on the latest version (14.0.1 as of today), but there seems to have compatibility issues. i also am using lit for the components, as well as pnpm and turborepo in the frontend repo in case that helps in anyway.
in
next dev
:or:
i'd like to point out that i'm using
createComponent
from @lit-labs/react to convert my "raw" Web Component into a React component, so this might be related:next build
: the following similar error happens for each statically rendered page, and also it does not break the build, DSD does not work, and FOUC/layout shift still happens since the web component isn't loaded immediately (like innext dev
):let me know if i can offer more information about my implementation or anything else, really looking forward to completing this implementation.