Complete the code to mark the component as a client component in Next.js.
"use client"; export default function [1]() { return <button>Click me</button>; }
The component is marked as a client component by adding "use client" at the top. The function name can be any valid name, here ClientButton is used.
Complete the code to import a client component inside a server component in Next.js.
import [1] from './ClientButton'; export default function ServerComponent() { return <div><[1] /></div>; }
Client components can be imported and used inside server components. The import name must match the exported client component name.
Fix the error in the client component by adding the missing directive.
"use client"; export default function ClientComponent() { return <button>Click me</button>; } // Missing directive: [1]
Client components in Next.js must start with the directive "use client" to enable client-side features like hooks and event handlers.
Fill both blanks to create a server component that renders a client component with a prop.
import [1] from './[2]'; export default function ServerComp() { return <div><ClientComp message="Hello" /></div>; }
The server component imports the client component named ClientComp from the file ClientComponent. Then it renders it with a prop.
Fill all three blanks to pass a callback from a server component to a client component.
import [1] from './[2]'; export default function ServerParent() { function handleClick() { console.log('Clicked'); } return <[3] onClick={handleClick} />; }
The server component imports the client component ClientComponent and passes a callback handleClick as a prop named onClick. The client component can then use this callback.