docs: clarify Client Components are pre-rendered during SSR#8489
docs: clarify Client Components are pre-rendered during SSR#8489LuxologyGG wants to merge 1 commit into
Conversation
Fixes reactjs#7223 The use-client reference incorrectly implied that Client Components are skipped during server rendering. Client Components are pre-rendered to HTML on the server and hydrated on the client.
Size changesDetails📦 Next.js Bundle Analysis for react-devThis analysis was generated by the Next.js Bundle Analysis action. 🤖 This PR introduced no changes to the JavaScript bundle! 🙌 |
|
I think we may need to do a more significant rewrite/rethinking of these pages. The model they're teaching is simplified and kind of incorrect, but we need to think about how to convey them well. The problem is that two worlds (Client and Server) have a very clean split; however, they don't have to map 1:1 to the physical "client" and "server". That's the key thing that we need to communicate somewhere. |
|
Thank you for the feedback. You're right that the current Client/Server Component model on this page is simplified. Issue #7223 specifically flagged the sentence implying Client Components are skipped during SSR, which contradicts how frameworks actually pre-render them to HTML. This PR only targets that inaccuracy: it clarifies pre-rendering on the server and hydration on the client, without attempting to address the broader 1:1 mapping between logical Client/Server boundaries and physical client/server runtimes. If a larger rewrite is the preferred path, I'm happy to close this PR and wait for direction on how you'd like that conceptual split communicated. Alternatively, if this targeted correction is still useful while a broader rethink is planned, I can keep it scoped to the SSR wording fix. Let me know which direction you'd prefer. |
|
Do you have any suggestions for how we could do this properly? The current description isn't correct for HTML-generating frameworks on the first render (but it is correct for next render, or for frameworks that skip HTML generation, since it's up to the framework to decide whether to do it or not). So strictly speaking your change wouldn't be fully correct either. It also makes the flow sound a lot more complicated when it's really more like two different things. One is the React Client and React Server trees. Another is how they get turned into HTML or other output formats. I don't have a specific idea for how to solve this at the moment. But I have a hunch that a proper explanation would still look more "symmetrical". |
Summary
Closes #7223
The
use clientreference incorrectly implied that Client Components are skipped during server rendering, when they are actually pre-rendered to HTML on the server and hydrated on the client.This PR clarifies that Client Components are pre-rendered on the server during SSR and updates the Client/Server Component definitions to reflect server pre-rendering plus client hydration.
Before / After
Before: "opting-out of evaluating any code imported from client-marked code" and Client Components defined as "rendered on the client."
After: Client Components are pre-rendered on the server to HTML, bundled separately, and hydrated on the client.
Verification
Documentation-only change.