Challenge - 5 Problems
Server Component Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate2:00remaining
Why are Server Components the default in Next.js?
Next.js uses Server Components as the default for rendering. What is the main reason for this choice?
Attempts:
2 left
💡 Hint
Think about how sending less code to the browser affects loading speed.
✗ Incorrect
Server Components run on the server and send only the rendered HTML to the client. This reduces JavaScript bundle size and improves page load speed.
❓ component_behavior
intermediate2:00remaining
What happens when a Server Component fetches data?
In Next.js, if a Server Component fetches data during rendering, what is the behavior seen on the client?
Attempts:
2 left
💡 Hint
Remember where Server Components run and when data fetching happens.
✗ Incorrect
Server Components run on the server, so data fetching happens there. The client receives the final HTML with data already included, avoiding extra client fetches.
❓ lifecycle
advanced2:00remaining
How do Server Components affect client-side lifecycle events?
Which statement correctly describes the effect of Server Components on client-side lifecycle events like useEffect?
Attempts:
2 left
💡 Hint
Think about where Server Components execute and what that means for client-only hooks.
✗ Incorrect
Server Components run only on the server, so hooks that depend on the client environment, like useEffect, do not run in them.
📝 Syntax
advanced2:00remaining
Identify the correct way to mark a component as a Server Component in Next.js
Which code snippet correctly marks a React component as a Server Component in Next.js?
NextJS
export default function MyComponent() { return <div>Hello from Server Component</div>; }
Attempts:
2 left
💡 Hint
Think about the default behavior of components in Next.js App Router.
✗ Incorrect
In Next.js App Router, components are Server Components by default. To make a component a Client Component, you add "use client" at the top.
🔧 Debug
expert3:00remaining
Why does this Server Component cause a runtime error?
Consider this Next.js Server Component code:
export default function UserProfile() {
const [count, setCount] = useState(0);
return ;
}
What is the cause of the runtime error?
Attempts:
2 left
💡 Hint
Think about which React hooks are allowed in Server Components.
✗ Incorrect
useState is a client-side hook and cannot be used in Server Components, which run only on the server. This causes a runtime error.