Next.js official documentation says
If you want to import and use a server component from a client component, you must pass it as props or children because an error will occur if you just import and use the component.
However, as a result of actually writing the code, I just imported and used the server component in the client component, but no error occurred.
The code I used is below.
// /app/test/page.tsx
'use client';
import Server from './Server';
const Page = () => {
return (
<div>
<h1>Client Component</h1>
<Server />
</div>
);
};
export default Page;
// /app/test/Server.tsx
const Server = () => {
return <div>I am Server</div>;
};
export default Server;
Is there something I've misunderstood or missed?
Due to "use client" directive, it seems that the component called from the Page also became a client component.
At this time, is there a way to keep the loaded component (Server) as a server component?