Background
Server-Side Rendering (SSR) is a technique in which the server generates the full HTML for a page on the server in response to navigation. This avoids additional round-trips for data fetching and templating on the client, since it’s handled before the browser gets a response(https://web.dev/rendering-on-the-web/). When it comes to web components, it means generating and serving the HTML of the web components, including shadow DOM and styles, before their JavaScript implementations have loaded and executed.
SSR can be used for a variety of reasons but performance is the most obvious one - some sites can render faster if they render static HTML first without waiting for JavaScript to load, then (optionally) load the page's JavaScript and hydrate the components.
Declarative Shadow DOM
Historically, it has been difficult to use Shadow DOM in combination with Server-Side Rendering because there was no built-in way to express Shadow Roots in the server-generated HTML. There are also performance implications when attaching Shadow Roots to DOM elements that have already been rendered without them. This can cause layout shifting after the page has loaded, or temporarily show a flash of unstyled content while loading the Shadow Root's stylesheets.
Declarative Shadow DOM removes this limitation, bringing Shadow DOM to the server - it's a element with a shadowrootmode attribute:
<host-element>
<template shadowrootmode="open">
<slot></slot>
</template>
<h2>Light content</h2>
</host-element>
A template element with the shadowrootmode attribute is detected by the HTML parser and immediately applied as the shadow root of its parent element. Loading the pure HTML markup from the above sample results in the following DOM tree:
<host-element>
#shadow-root (open)
<slot>
↳
<h2>Light content</h2>
</slot>
</host-element>
Declarative Shadow DOM Support
Feature Request
As an application developer I would like to server-side my app, built UI5 Web Components could support some of the popular frameworks - like Next.js as described in FR #2240 by @MarcusNotheis
Tasks
Additional Context
Lit already have done some progress on the topic and provides the @lit-labs/ssr package for server-side rendering Lit templates and components.
As we internally reuse lit templates, we have to look into that implementation and available integrations with server side frameworks- KOA, Astro
Related Issues
#2240
#6192
Priority
A clear and concise description of the impact/urgency of the required feature.
Stakeholder Info (if applicable)
- Organization: {...}
- Business impact: {...}
Background
Server-Side Rendering (SSR)is a technique in which the server generates the full HTML for a page on the server in response to navigation. This avoids additional round-trips for data fetching and templating on the client, since it’s handled before the browser gets a response(https://web.dev/rendering-on-the-web/). When it comes to web components, it means generating and serving the HTML of the web components, including shadow DOM and styles, before their JavaScript implementations have loaded and executed.SSRcan be used for a variety of reasons but performance is the most obvious one - some sites can render faster if they render static HTML first without waiting for JavaScript to load, then (optionally) load the page's JavaScript and hydrate the components.Declarative Shadow DOM
Historically, it has been difficult to use
Shadow DOMin combination withServer-Side Renderingbecause there was no built-in way to express Shadow Roots in the server-generated HTML. There are also performance implications when attaching Shadow Roots to DOM elements that have already been rendered without them. This can cause layout shifting after the page has loaded, or temporarily show a flash of unstyled content while loading the Shadow Root's stylesheets.Declarative Shadow DOMremoves this limitation, bringing Shadow DOM to the server - it's a element with ashadowrootmodeattribute:A template element with the shadowrootmode attribute is detected by the HTML parser and immediately applied as the shadow root of its parent element. Loading the pure HTML markup from the above sample results in the following DOM tree:
Declarative Shadow DOM Support
Feature Request
As an application developer I would like to server-side my app, built UI5 Web Components could support some of the popular frameworks - like Next.js as described in FR #2240 by @MarcusNotheis
Tasks
Additional Context
Litalready have done some progress on the topic and provides the @lit-labs/ssr package for server-side rendering Lit templates and components.As we internally reuse lit templates, we have to look into that implementation and available integrations with server side frameworks- KOA, Astro
Related Issues
#2240
#6192
Priority
A clear and concise description of the impact/urgency of the required feature.
Stakeholder Info (if applicable)