-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add support for (progressive) hydration for compatible renderers #880
Labels
Milestone
Comments
5 tasks
globalThis
state?)globalThis
state?)
globalThis
state?)globalThis
for state?)
This was referenced May 29, 2022
globalThis
for state?)globalThis
for state?)
This was referenced Oct 14, 2023
12 tasks
16 tasks
globalThis
for state?)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
Type of Change
Summary
At it simplest, in the context of server or pre-rendering, hydration is the ability for a client side library to re-use the existing HTML (often generated by same client library on the server side) so that on load of the page, the client side library can avoid having to do any DOM manipulation and just build up its internal state / event handers from the existing inert HTML on the page already. This really help with things like Cumulative Layout Shift (CLI) and Time to Interactive (TTI) which are a part of core web vitals.
I think this should be a feature turned off by default, and that can be enabled via greenwood.config.js.
Details
Libraries like Lit provide such a capability (which will be the pilot for this particular issue though I do want roll our own at some point in service of #548 ) but in the context where data comes into play, that same data must be present in the client as well to ensure that server and client HTML match.
Thus Greenwood needs to expose / inject data somehow into the system we have set up, or alter it to be more accommodating. For static prerendering, this may require another approach since it won't be coming from a [route].js file. My initial hunch is to follow a similar convention as per
interpolateFrontmatter
and just stuff everything intoglobalThis
as per #1005 , e.g.Will also want to add this for WCC using
metadata
Also should support different strategies like eager or lazy loading.
Coming out of https://github.com/ProjectEvergreen/greenwood/pull/1157/files#r1359495833, I think we have the mechanism by which to orchestrate this now, and it can be opt-in without any specification configuration. The gist being any SSR page can export a
loader
function, which Greenwood can use toloader
function allows us to serialize the props for further hydration at runtime.That said, if SSR pages never have their code sent to the client, is any of this needed? A page could also SSR the data right into their child components like in this example?, e.g.
Could be worth looking into WCCG Context Community Protocol. We can even consider making it opt-in, e.g.
Or else maybe there is a use case to ship the SSR page code to the client? 🤔
The pilot for this can be Lit's SSR hydration support added in #1201
and WCC
The text was updated successfully, but these errors were encountered: