from here (thanks to Paul Serre for commenting)
The root layout is a Server Component by default and can not be set to
a Client Component.
in app directory, server components can render client components but client components cannot render server components. the only exception is if the client component renders component which is passed as children. this is a Layout. From the same docs:
Layouts are Server Components by default but can be set to a Client
Component.
"use client";
export default function Layout({children}: {
children: React.ReactNode
}) {
return (
<html lang="en">
<head />
<body>{children}</body>
</html>
)
}
Since the root layout component is rendering children
, any component inside children
tree can be server component
this would not be accepted
"use client";
export default function Layout({children}: {
children: React.ReactNode
}) {
return (
<html lang="en">
<head />
<body>
// if you manually pass server component inside client component
<AnyServerRenderedComponent/>
</body>
</html>
)
}