Are sever components running on an actual sever? Can someone explain?

Next js question. Why can’t we import sever components into client components directly? I know we can pass sever components as props, but why only this way? And are the actual sever components running on an actual sever? Can someone explain?
4 Replies
whatplan
whatplan13mo ago
server components only ever run on the server you cant import them into a client component because that would mean running them on the server after the page is already on the client (client -> server waterfall) which the whole idea is to avoid you can pass server components as props because they can be run on the server and then passed down over the server/client boundary to be used on the client
<Client>
<Server>
</Client>
<Client>
<Server>
</Client>
The client stuff can change really do whatever but you can think of the server component in the middle as essentially static html that never changes once you get the the client
cje
cje13mo ago
the short answer is yes they do run on the server they get sent to the client as basically html (with slots for client components etc) you can for example query your database directly in a server component, so being able to do that from the client is not possible
cje
cje13mo ago
cje
cje13mo ago
this might help explain why you can use RSCs with the children prop?