Next.js Discord

Discord Forum

Understanding server & client component

Answered
Transvaal lion posted this in #help-forum
Open in Discord
Transvaal lionOP
if i use "use client" in parent component in next.js, do child components also treated as client component?
Answered by Asian black bear
No.
View full answer

10 Replies

Asian black bear
No.
Answer
Asian black bear
You can interleave server and client components.
@Asian black bear You can interleave server and client components.
Transvaal lionOP
Thanks
well, I have a diferent view from @Asian black bear
in Next.js, if you use "use client" in a parent component, all child components will also be treated as client components. The "use client" directive indicates that the component should be rendered on the client side, and this behavior propagates down to its children.
Asian black bear
This is not a matter of opinion. Children of client components can still be server components as they are prerendered on the server and slotted in afterwards. They don't miraculously become client components with their usual set of features just because a parent component is a client component, they are still server components after all.
Transvaal lionOP
here is the screenshot from docs.
Btw you can only mark one message as solution so I remarked to the one most deserving
👏