Skip to content

Navigation Menu

Sign in
Sign up

Streaming data hydration and Promise de/rehydration #3

Ephem started this conversation in Q&A
Discussion options

I just re-read the Library Upgrade Guide: <script> (e.g. SSR frameworks) over in the React 18 WG and wasn't sure if I should post questions here or over there, but since it's related to RSCs and this WG exists now, I thought I'd just put it here.

From that post:

The real trick is when you use Suspense to do you data fetching during the stream. In that case you might discover new data as you go. This isn't quite supported in the React 18 MVP. When it's fully supported this will be built-in so that the serialization is automatic.

The next step will be to have data serialization with React Server Components work out of the box. That way if you load your data with Server Components, you don't have to manually wire up that data for hydration purposes. We might also add more options for other React I/O providers.

I'm thinking about streaming data hydration for libraries like React Query, do you have any more insight into how these parts will work now? I've understood Promise de/rehydration will be a mechanism which seems great and I get how that will work RSC -> Client Components (on the server), but I'm specifically wondering two things:

  • (削除) Will React also automatically hydrate these Promises RSC -> Client Component (on the client)? (Guessing yes, and that React will take care of the ordering issues of what to resolve first etc?) (削除ここまで)
  • Will there be a way to leverage this without RSCs? That is, if you wanted to also support "just" streaming SSR with incremental/selective React hydration, or discovering and fetching extra queries during the SSR pass, would there be a built in way for that as well? If so, are there any thoughts to what that would look like, would it also be Promise based for example or something else?

Without the second, it would be hard to support SSR for the case useQuery(..., { suspense: true }) without first preloading in an RSC?

In no rush for answers, I get if this isn't fleshed out yet, just thinking through the various cases we'd want to support. 😃

You must be logged in to vote

Replies: 0 comments

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant

AltStyle によって変換されたページ (->オリジナル) /