Challenge - 5 Problems
Zero Bundle Size Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ component_behavior
intermediate2:00remaining
What is the output of this Server Component rendering?
Consider this Next.js Server Component code. What will be rendered in the browser?
NextJS
export default function Greeting() { const message = 'Hello from server!'; return <h1>{message}</h1>; }
Attempts:
2 left
💡 Hint
Server Components render HTML on the server and send it as static markup.
✗ Incorrect
The component returns an element with the server-side message. This renders as
element with the server-side message. This renders as Hello from server!
in the browser.
❓ state_output
intermediate2:00remaining
What happens if you use useState in a Server Component?
Given this Server Component code, what will happen when you try to run it?
NextJS
import { useState } from 'react'; export default function Counter() { const [count, setCount] = useState(0); return <button onClick={() => setCount(count + 1)}>{count}</button>; }
Attempts:
2 left
💡 Hint
Server Components do not support React hooks like useState.
✗ Incorrect
useState is a React hook for client-side state. Server Components run only on the server and cannot use client hooks, causing a syntax or build error.
📝 Syntax
advanced2:00remaining
Which option correctly marks a component as a Server Component in Next.js?
Select the code snippet that correctly defines a Server Component with zero client bundle size.
Attempts:
2 left
💡 Hint
Server Components do not need a special directive; client components use "use client".
✗ Incorrect
In Next.js, components are Server Components by default. Adding "use client" marks them as Client Components. "use server" is not a valid directive.
🔧 Debug
advanced2:00remaining
Why does this Server Component cause a client bundle to be generated?
Analyze the code below. Why does it cause Next.js to include client-side JavaScript in the bundle?
NextJS
import { useState } from 'react'; export default function Example() { return <button onClick={() => alert('Clicked!')}>Click me</button>; }
Attempts:
2 left
💡 Hint
Event handlers require client-side interactivity.
✗ Incorrect
Using onClick requires the component to be interactive on the client, so Next.js bundles client JavaScript even if useState is not used.
🧠 Conceptual
expert3:00remaining
How does Next.js achieve zero bundle size for Server Components?
Choose the best explanation for how Next.js ensures Server Components have zero client bundle size.
Attempts:
2 left
💡 Hint
Think about where Server Components run and what is sent to the browser.
✗ Incorrect
Server Components run only on the server and produce HTML. Their code is not sent to the client, so no JavaScript bundle is created for them.