Complete the code to mark a component as a server component in Next.js.
"use client" directive is for client components, so for server components, [1] at the top.
In Next.js App Router, components are server components by default with no directive. This ensures zero bundle size on the client as they render entirely on the server. "use server" is reserved for Server Actions.
Complete the code to import a server component correctly without increasing client bundle size.
import ServerComponent from '[1]';
.client file which increases bundle sizeA common convention is to use the .server file suffix for server-only components. This clarifies intent and helps avoid accidental client bundling, contributing to zero client bundle size.
Fix the error in this server component export to ensure zero client bundle size.
export default function [1]() { return <div>Server Component</div>; }
Naming the function ServerComponent clarifies its role as a server component. Ensure no "use client" directive is present in the file for zero client bundle size.
Fill both blanks to create a server component that fetches data without adding to client bundle size.
export default async function [1]() { const data = await fetch('[2]'); return <div>{JSON.stringify(data)}</div>; }
The component is named ServerDataComponent (server by default) and fetches data from a server API URL on the server side. No client bundle increase since it runs server-only.
Fill all three blanks to create a server component that imports a client component and passes data correctly.
import ClientComponent from [1]; export default async function [2]() { const data = await fetch('[3]'); return <ClientComponent data={data} />; }
The server component (default) imports the client component from a .client file (convention), fetches serializable data on the server from an API, and passes it as props to the client component. Keeps client bundle minimal.