A server component is a React component that runs only on the server. It fetches data and renders HTML before sending it to the browser, improving performance and reducing client-side JavaScript.
Click to reveal answer
beginner
Why are server components the default in Next.js 14+?
Server components are default because they reduce the amount of JavaScript sent to the browser, improve load speed, and simplify data fetching by running on the server.
Click to reveal answer
intermediate
How do server components improve user experience?
They send fully rendered HTML to the browser quickly, so users see content faster. This reduces waiting time and improves accessibility and SEO.
Click to reveal answer
beginner
What is a key difference between server and client components in Next.js?
Server components run only on the server and do not include client-side JavaScript, while client components run in the browser and handle interactivity.
Click to reveal answer
intermediate
How does using server components affect bundle size?
Using server components reduces the JavaScript bundle size sent to the browser because server logic stays on the server, making pages lighter and faster.
Click to reveal answer
Why does Next.js make server components the default?
ATo improve page load speed by sending less JavaScript to the browser
BTo force all code to run on the client
CTo increase the size of JavaScript bundles
DTo disable server-side rendering
✗ Incorrect
Server components reduce client-side JavaScript, improving load speed and performance.
Which of these runs only on the server in Next.js?
AClient components
BServer components
CBoth client and server components
DNone of the above
✗ Incorrect
Server components run only on the server and do not send JavaScript to the client.
What is a benefit of server components for SEO?
AThey send fully rendered HTML to search engines
BThey delay content rendering
CThey hide content from search engines
DThey require JavaScript to show content
✗ Incorrect
Server components send ready HTML, making content easy for search engines to read.
How do server components affect JavaScript bundle size?
AThey increase bundle size
BThey have no effect
CThey reduce bundle size by keeping code on the server
DThey move all code to the client
✗ Incorrect
Server components keep logic on the server, reducing JavaScript sent to the client.
Which is true about client components in Next.js?
AThey run only on the server
BThey reduce JavaScript bundle size
CThey are the default in Next.js 14+
DThey handle interactivity in the browser
✗ Incorrect
Client components run in the browser and manage user interactions.
Explain why Next.js uses server components as the default for rendering pages.
Think about how server components help users see content faster.
You got /4 concepts.
Describe the main differences between server components and client components in Next.js.
Consider where the code runs and what it does.
You got /4 concepts.
Practice
(1/5)
1. Why are server components the default in Next.js?
easy
A. They allow direct access to browser events and state management.
B. They improve speed by running on the server and sending only HTML to the browser.
C. They require less server resources by running on the client.
D. They enable real-time updates without refreshing the page.
Solution
Step 1: Understand server component behavior
Server components run on the server and send only HTML to the browser, reducing data transfer and improving speed.
Step 2: Compare with client components
Client components handle browser events and state, but server components focus on fast, secure rendering.
Final Answer:
They improve speed by running on the server and sending only HTML to the browser. -> Option B
Quick Check:
Server components = faster, secure HTML delivery [OK]
Hint: Server components send HTML, client components handle events [OK]
Common Mistakes:
Confusing server components with client-side event handling
Thinking server components run in the browser
Assuming server components manage state like client components
2. Which of the following is the correct way to mark a component as a client component in Next.js?
easy
A. Use export default clientComponent() syntax.
B. Wrap the component in <ClientComponent> tags.
C. Add the directive use client at the top of the file.
D. Add client: true in the component props.
Solution
Step 1: Recall client component syntax
In Next.js, to mark a component as client-side, you add the directive use client at the very top of the file.
Step 2: Eliminate incorrect options
Wrapping in tags, special export syntax, or props flags are not valid ways to mark client components.
Final Answer:
Add the directive use client at the top of the file. -> Option C
Quick Check:
Client component directive = 'use client' [OK]
Hint: Client components start with 'use client' directive [OK]
Common Mistakes:
Trying to mark client components with props or wrappers
Placing 'use client' inside the component body
Confusing export syntax with client directives
3. Consider this Next.js component code:
export default function Page() {
return (
<div>Hello from server component</div>
)
}
What will the browser receive when this page loads?
medium
A. Plain HTML content: <div>Hello from server component</div>.
B. An error because no client directive is present.
C. A fully interactive React component with event handlers.
D. Empty content because server components do not render.
Solution
Step 1: Identify component type
The component has no 'use client' directive, so it is a server component by default.
Step 2: Understand server component output
Server components render HTML on the server and send plain HTML to the browser without React event handlers.
Final Answer:
Plain HTML content: <div>Hello from server component</div>. -> Option A
Quick Check:
Server component output = plain HTML [OK]
Hint: No 'use client' means server component sends HTML only [OK]
Common Mistakes:
Expecting React interactivity without 'use client'
Thinking server components cause errors without client directive
Assuming server components send JavaScript to browser
What is the main problem with this code in Next.js 13+?
medium
A. Buttons cannot have event handlers in Next.js.
B. The useState hook is not imported from React.
C. The arrow function in onClick is invalid syntax.
D. It lacks the use client directive, so state and events won't work.
Solution
Step 1: Check component type and hooks usage
The component uses React state and event handlers, which require client-side execution.
Step 2: Identify missing client directive
Without the 'use client' directive at the top, this component is treated as a server component, so hooks and events won't work.
Final Answer:
It lacks the use client directive, so state and events won't work. -> Option D
Quick Check:
State + events need 'use client' directive [OK]
Hint: State or events require 'use client' directive [OK]
Common Mistakes:
Forgetting to add 'use client' for interactive components
Assuming hooks work in server components
Thinking arrow functions cause syntax errors here
5. You want to build a Next.js page that fetches data securely on the server and shows a button that increments a counter on click. How should you organize your components?
hard
A. Use a server component for data fetching and embed a client component for the button with state.
B. Make the entire page a client component to handle data fetching and button state.
C. Use only server components because client components are slower.
D. Fetch data in the client component and handle button state in the server component.
Solution
Step 1: Separate concerns by component type
Data fetching is best done in server components for security and speed, while interactive UI needs client components.
Step 2: Combine server and client components properly
Use a server component to fetch and render data, then include a client component inside it for the button with state and events.
Final Answer:
Use a server component for data fetching and embed a client component for the button with state. -> Option A
Quick Check:
Server fetch + client interactivity = best practice [OK]
Hint: Fetch on server, interactive parts on client [OK]
Common Mistakes:
Making entire page client-side losing server benefits
Trying to fetch data inside client components
Mixing state logic in server components
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.