Recall & Review
beginner
What is a client component in Next.js?
A client component is a React component that runs in the browser. It can handle user interactions like clicks and input changes because it has access to browser APIs and state management.
Click to reveal answer
beginner
Why do client components handle interactivity instead of server components?
Client components handle interactivity because they run in the browser where users interact. Server components run on the server and cannot respond directly to user actions or browser events.
Click to reveal answer
intermediate
How does Next.js decide which components should be client components?
Next.js uses the 'use client' directive at the top of a file to mark a component as a client component. This tells Next.js to bundle it for the browser so it can handle interactivity.
Click to reveal answer
intermediate
What happens if you try to use browser-only features in a server component?
It will cause errors because server components run on the server where browser APIs like 'window' or 'document' do not exist. Only client components can safely use these features.
Click to reveal answer
beginner
How do client components improve user experience in Next.js apps?
Client components allow immediate response to user actions without waiting for server responses. This makes apps feel faster and more interactive, like clicking buttons or typing in forms.
Click to reveal answer
Which component type in Next.js handles user clicks and input changes?
✗ Incorrect
Client components run in the browser and handle user interactions like clicks and inputs.
What directive marks a React component as a client component in Next.js?
✗ Incorrect
The 'use client' directive tells Next.js to treat the component as a client component.
Why can't server components handle browser events directly?
✗ Incorrect
Server components run on the server and do not have access to browser APIs needed for events.
What will happen if you use 'window' inside a server component?
✗ Incorrect
'window' is a browser API and is not available on the server, causing errors.
How do client components affect app speed and feel?
✗ Incorrect
Client components handle interactions immediately in the browser, improving responsiveness.
Explain why Next.js uses client components to handle interactivity instead of server components.
Think about where user actions happen and where code runs.
You got /4 concepts.
Describe how you would make a React component in Next.js handle user clicks and input changes.
Focus on marking the component and handling events.
You got /4 concepts.