Challenge - 5 Problems
Next.js Server-First Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ component_behavior
intermediate2:00remaining
What is the output of this Next.js Server Component?
Consider this Next.js Server Component that fetches data and renders it. What will the user see when this component is rendered?
NextJS
import React from 'react'; async function getData() { return { message: 'Hello from server!' }; } export default async function Greeting() { const data = await getData(); return <h1>{data.message}</h1>; }
Attempts:
2 left
💡 Hint
Remember that Next.js Server Components can use async/await to fetch data before rendering.
✗ Incorrect
Next.js Server Components run on the server and can await data fetching before rendering. So the component renders the fetched message directly.
❓ lifecycle
intermediate1:30remaining
When does Next.js Server Component code run?
In Next.js's server-first rendering model, when does the code inside a Server Component execute?
Attempts:
2 left
💡 Hint
Think about where server components run and when the HTML is generated.
✗ Incorrect
Server Components run only on the server during the initial request to generate HTML. They do not run on the client.
📝 Syntax
advanced2:00remaining
Which option correctly defines a Next.js Client Component?
Next.js uses special syntax to mark Client Components. Which of these options correctly marks a component as a Client Component?
Attempts:
2 left
💡 Hint
Client Components require a special directive at the top of the file.
✗ Incorrect
Next.js requires the "use client" directive at the top of the file to mark a component as a Client Component.
🔧 Debug
advanced2:00remaining
Why does this Next.js Server Component cause a runtime error?
Examine this Server Component code. Why will it cause an error when rendered?
NextJS
import React from 'react'; export default function ServerComp() { const [count, setCount] = React.useState(0); return <div>{count}</div>; }
Attempts:
2 left
💡 Hint
Think about hooks and where they can be used in Next.js components.
✗ Incorrect
React hooks like useState only work in Client Components. Server Components cannot use hooks that require client state.
🧠 Conceptual
expert2:30remaining
How does Next.js handle data fetching in Server Components for SEO and performance?
Which statement best describes how Next.js Server Components improve SEO and performance through data fetching?
Attempts:
2 left
💡 Hint
Think about when the HTML is generated and what the client receives.
✗ Incorrect
Next.js Server Components fetch data on the server before rendering, so the HTML sent to the client already contains the data. This improves SEO and reduces client load time.