3 ms·
> You Can't SSR a Web Component - Strictly speaking, this is not quite correct. Custom elements are just html tags and can be rendered by any server framework.
by GordonS 6y ago
> You Can't SSR a Web Component - Strictly speaking, this is not quite correct. Custom elements are just html tags and can be rendered by any server framework. If you want to SSR the shadow DOM itself, that's possible by inlining the template and using a small bit of JS to attach the shadow after streaming the template in. That said, as mentioned, we are working on declarative shadow dom, which will provide the W3C standard on which SSR and other WC capabilities will be built.
I mainly develop using ASP.NET Core, with some vanilla JS as needed.
I'm just starting to hear about Web Components, and have heard that you can't use them with SSR because of the shadow DOM. I don't actually know what shadow DOM is, but does this mean no Web Components work with SSR, or that some don't? What precisely is the issue?
- lioeters 6y agoAccording to a fairly recent article (Feb 2020): > It's a common myth that you can't server side render Web Components. Turns out you can if you look in the right place. https://dev.to/steveblue/server-side-rendering-web-components-320g https://dev.to/steveblue/server-side-rendering-web-component... The article mentions a few libraries for this purpose. - Vaadin Router - https://vaadin.com/router https://vaadin.com/router - SkateJS - https://skatejs.netlify.app/ https://skatejs.netlify.app/ - SkateJS: Web component server-side rendering - https://github.com/skatejs/skatejs/tree/master/packages/ssr https://github.com/skatejs/skatejs/tree/master/packages/ssr This latter looks good, I hadn't seen that before. As a possible successor to React, Vue, et al, there's a wide range of functionality expected of Web Components. Server-side rendering of shadow DOM (I don't know what that really means, but) seems to be one of the tough questions yet to find a definitive answer.