v0.3.45
React Streaming. Full-fledged & Easy.
Repository
Current version released
8 months ago
Versions
- v0.4.3Latest
- v0.3.50
- v0.4.2
- v0.4.1
- v0.4.0
- v0.3.49
- v0.3.48
- v0.3.47
- v0.3.46
- v0.3.45
- v0.3.44
- v0.3.43
- v0.3.42
- v0.3.41
- v0.3.40
- v0.3.39
- v0.3.38
- v0.3.37
- v0.3.36
- v0.3.35
- v0.3.34
- v0.3.33
- v0.3.32
- v0.3.31
- v0.3.30
- v0.3.29
- v0.3.28
- v0.3.27
- v0.3.26
- v0.3.25
- v0.3.24
- v0.3.23
- v0.3.22
- v0.3.21
- v0.3.20
- v0.3.19
- v0.3.18
- v0.3.17
- v0.3.16
- v0.3.15
- v0.3.14
- v0.3.13
- v0.3.12
- v0.3.11
- v0.3.10
- v0.3.9
- v0.3.8
- v0.3.7
- v0.3.6
- v0.3.5
- v0.3.4
- v0.3.3
- v0.3.2
- v0.3.1
- v0.3.0
- v0.2.23
- v0.2.22
- v0.2.21
- v0.2.20
- v0.2.19
- v0.2.18
- v0.2.17
Injecting Into the SSR Stream
Rule 1
Nothing should be injected between two React synchronous writes.
- According to Reactâs team, chunks should be injected âbefore React writesâ: https://github.com/reactwg/react-18/discussions/114#:~:text=Injecting%20Into%20the%20SSR%20Stream
- In practice, chunks indeed cannot be arbitrarily injected, as the app will eventually crash otherwise.
- It isnât clear what âbefore React writesâ means. I interpret it like this: nothing should be injected between two React synchronous writes.
- So far, my interpreted rule seems to be working.
- Itâs also the interpretation of the Apollo GraphQL team: https://github.com/apollographql/apollo-client-nextjs/issues/325#issuecomment-2205375796
Rule 2
Nothing should be injected before the first React write.
- This doesnât seem to be documented by the React team.
- But, in practice, there seems to (always?) be a hydration mismatch if anything is injected before the first React write.
- Reproduction: https://github.com/vikejs/vike/commit/45e4ffea06335ddbcf2826b0113be7f925617daa
- Thus, we delay any write to the stream until React writes its first chunk.
- Because of Rule 1, all subsequent synchronous React write after the first one also need to be injected first.
Chunk promises
Being able to pass a chunk promise to injectToStream()
is required for integrating Apollo GraphQL, see: