1

So, if I understood how server components work, it will return the html to clients, and then, after loading the initial javascript bundle, it will get from the server a json file to represent its virtual DOM node to hydrate the initial html from that component.

But, in NextJS, server components cannot have client-side logic, which means the only part of the HTML from those components that can be mutated based on client state or that can emit events is inside client components.

So, what is the point of hydrating all the markup if we will not use it? Beside running server-side logic before rendering the components, is there any advantage in doing that instead of just making sure that the server and clients run the same javascript to hydrate or create the HTML?

1 Answers1

1
  • Data from server components is sent as JSON to the client. the client still has to build DOM from this JSON data.

  • server components can also render client components.

eventually, server components go to the client and the client has to create proper structure for the users

Yilmaz
  • 35,338
  • 10
  • 157
  • 202