DEV Community

Robert Rees
Robert Rees

Posted on

Server-side rendered Web Components

I recently wrote a post about why I thought Web Components were finally having a moment and the comment thread was filled with a lot of discussion about server-side rendering that I felt missed the point that Web Components are primarily about adding interactivity to web pages rather than being a component system for building them. When I wrote the post I assumed that people would create the content using server-side rendering as they would normally.

However since I wrote that post the Enhance WASM (Github repo) actually allows you to server-side render Web Components which makes the question more than an odd hypothetical.

I'm still not sure that most organisations and developers actually have a use case for needing server-side rendered Web Components. I feel that often server-side rendered React is mostly about developers not having to learn another templating language on top of JSX, but if it matters to you then it is now at least possible.

Top comments (3)

Collapse
 
sirajulm profile image
Sirajul Muneer

I don't think web components are mere adding interactivity to web pages. I'm not sure above Enhance WASM, but there is still lacking for shadow root / shadow dom for server side rendering which is the major bottle neck.
Do organisations have a need to SSR. Yes in a very competitive world, to have the content being served to the users, to have them indexed well by search engines (without having to create some hacky ways), to serve static contents like blogs or wikis SSR or static site rendering is quite a need. We no longer live in the fancy world of Angularjs anymore. That is gone, and people have come to reality, that the server rendered contents of old php world was actually great. This is a time were we choose frameworks and technologies that gives the best of both worlds.

Only place SSR is irrelavant is when creating internal tools.

Collapse
 
rrees profile image
Robert Rees

I think you're confusing the need for server-side rendering and server-side rendering of Web Components. If you've actually got a use-case (perhaps one which demonstrates the need for a server-side ShadowDOM implementation) I'd be interested to hear it.

My basic position is that Web Components play an important role in traditional progressive enhancement techniques rather than being a React or Angular alternative.

Collapse
 
jonathan_santos_830e37539 profile image
Jonathan DS

I'm not in the loop to talk about web components but, the main reason I ever research and use SSR is SEO.

Even if search engines can render JS, there will be plenty of discussion around the topic and SEO people will want to have stuff rendered on the backend.