Challenge - 5 Problems
Server Component Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate2:00remaining
Why keep a component on the server in Next.js?
In Next.js, what is a main reason to keep a component rendered on the server instead of the client?
Attempts:
2 left
💡 Hint
Think about what search engines see when content is server-rendered.
✗ Incorrect
Server components render HTML on the server, so search engines can read content easily, improving SEO.
❓ component_behavior
intermediate2:00remaining
What happens if a server component tries to use client hooks?
Consider a Next.js server component that tries to use
useState hook. What will happen?Attempts:
2 left
💡 Hint
Remember which hooks are allowed only in client components.
✗ Incorrect
Server components cannot use client-only hooks like useState. Trying to do so causes a build error.
❓ state_output
advanced2:00remaining
State behavior in server vs client components
Given a Next.js app with a server component rendering a client component inside it, where is the state stored and updated?
Attempts:
2 left
💡 Hint
Think about where hooks like useState run.
✗ Incorrect
State hooks like useState run only in client components, so state lives and updates in the browser.
📝 Syntax
advanced2:00remaining
Correct syntax to mark a component as client in Next.js
Which of the following is the correct way to mark a React component as a client component in Next.js 14+?
Attempts:
2 left
💡 Hint
Look for the special directive string.
✗ Incorrect
Next.js uses the special directive "use client"; at the top of the file to mark client components.
🔧 Debug
expert3:00remaining
Why does this server component fail to render?
This Next.js server component imports a client component but does not mark it correctly. What error will occur?
NextJS
import ClientButton from './ClientButton'; export default function ServerComp() { return <ClientButton />; }
Attempts:
2 left
💡 Hint
Check if the client component file has the correct directive.
✗ Incorrect
Client components must have "use client" directive. Importing a client component without it causes a build error.