v0.3.43
React Streaming. Full-fledged & Easy.
Repository
Current version released
2 months ago
Versions
- v0.3.43Latest
- 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: