Recall & Review
beginner Click to reveal answer
What is a client component in Next.js?
A client component is a React component that runs in the browser. It can use browser-only features like state, effects, and event handlers.
beginner Click to reveal answer
When should you use a client component in Next.js?
Use client components when you need interactivity, like handling user input, animations, or dynamic updates that happen in the browser.
intermediate Click to reveal answer
Why can't server components handle user events in Next.js?
Server components run on the server and do not have access to browser APIs or user events, so they can't handle clicks or input changes directly.
beginner Click to reveal answer
How do you mark a component as a client component in Next.js?
Add the directive 'use client' at the top of the component file to tell Next.js to treat it as a client component.
intermediate Click to reveal answer
Can client components use server components inside them in Next.js?
No, client components cannot include server components, but server components can include client components.
Which of the following is a reason to use a client component in Next.js?
✗ Incorrect
Client components handle user interactions like clicks and input because they run in the browser.
How do you tell Next.js that a component should be a client component?
✗ Incorrect
The 'use client' directive at the top marks the component as a client component.
Which statement is true about client and server components?
✗ Incorrect
Server components can include client components, but client components cannot include server components.
What feature can only client components use in Next.js?
✗ Incorrect
Hooks like useState and useEffect require running in the browser, so only client components can use them.
If you want to add a button that changes text when clicked, which component type should you use?
✗ Incorrect
Client components handle user events like clicks, so use a client component for interactive buttons.
Explain why and when you should use client components in Next.js.
Think about what needs to happen in the browser versus on the server.
You got /4 concepts.
Describe the relationship between client and server components in Next.js and how they can be combined.
Consider which components can contain which and where they run.
You got /4 concepts.
