Skip to content

[Typo]: Client Components running on the server #7223

Open
@joshwcomeau

Description

Summary

The "use client" docs state:

During render, the framework will server-render the root component and continue through the render tree, opting-out of evaluating any code imported from client-marked code.

The server-rendered portion of the render tree is then sent to the client. The client, with its client code downloaded, then completes rendering the rest of the tree.

This implies that Client Components are skipped during SSR, but I don’t think that’s true.

Page

https://react.dev/reference/rsc/use-client

Details

My understanding is that Client Components will render on the server during SSR, and hydrate on the client. This is necessary so that the server-generated HTML is complete; if Client Components were truly skipped during SSR, our HTML would be full of holes that would only be filled in after hydration.

Another way to verify this is to add a console.log() to a Client Component, within a component function. The log will be printed in our server terminal, showing that the code is indeed evaluated on the server.

It’s possible I'm misunderstanding what is meant by "render" in this context, but it really makes it sound like the server skips any files that are marked with "use client". And unless this changed very recently, it is demonstrably untrue.

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions