Closed crisberrios closed 4 months ago
How about onBeforeRenderClient()
? (Note pageContext.isHydration
.)
PR welcome, but I can also do it once I'm done with the head management redesign.
That works, I'll give it a shot, thank you.
Pre-released as 0.4.8-commit-68be831
Currently, we have access to data and onBeforeRender on the SSR pass, but we don't have a way to execute code before the hydration pass. This limits the ability to hydrate stores and forces us to do additional render passes.
example:
Then on the client side:
Ideally, the store would be already hydrated before the hydration pass. This could be achieved by adding a custom hook such as
+onBeforeHydration
.For my use case, making this a simple hook with a signature like `(pageContext) => void) would suffice, but for ergonomics, I think this could/should also work as a middleware, support async, and return pageContext.
For my example, this would look like:
and an async use case
This would be similar, if not the same as #96
It may also help solve #87 and #57.