We've been utilizing a pattern for generating React components from our lit framework, aimed at encapsulating custom elements. This approach dynamically imports components using React.lazy and waits for the custom element definition using customElements.whenDefined. Here's a snippet for context:
While this pattern works well in client-side environments, we've encountered issues when integrating with server-side rendering (SSR) frameworks, such as Next.js. The reliance on customElements.whenDefined and dynamic imports via React.lazy poses challenges in SSR contexts, leading to rendering issues or failures when attempting to prerender these components.
We've been utilizing a pattern for generating React components from our lit framework, aimed at encapsulating custom elements. This approach dynamically imports components using React.lazy and waits for the custom element definition using customElements.whenDefined. Here's a snippet for context:
While this pattern works well in client-side environments, we've encountered issues when integrating with server-side rendering (SSR) frameworks, such as Next.js. The reliance on customElements.whenDefined and dynamic imports via React.lazy poses challenges in SSR contexts, leading to rendering issues or failures when attempting to prerender these components.