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 SEO.
Click to reveal answer
beginner
How does the Server Component execution model improve app performance?
By running components on the server, it reduces JavaScript sent to the client, speeds up page load, and allows data fetching without blocking the UI.
Click to reveal answer
beginner
Where does the Server Component code run in Next.js?
Server Component code runs only on the server during the rendering phase. It never runs in the browser.
Click to reveal answer
intermediate
What happens when a Server Component fetches data?
The data is fetched on the server before rendering. The server sends fully rendered HTML to the client, so the browser shows content immediately.
Click to reveal answer
intermediate
Can Server Components use React hooks like useState or useEffect?
No. Server Components cannot use client-only hooks like useState or useEffect because they do not run in the browser.
Click to reveal answer
Where does a Next.js Server Component run?
ABoth server and browser
BOnly in the browser
COnly on the server
DOn the client side only
✗ Incorrect
Server Components run only on the server during rendering.
What is a key benefit of Server Components in Next.js?
AThey reduce JavaScript sent to the client
BThey allow useState on the server
CThey run faster in the browser
DThey replace API routes
✗ Incorrect
Server Components reduce client JavaScript by rendering on the server.
Can Server Components use useEffect hook?
AYes, always
BNo, because they don't run in the browser
COnly with special flags
DOnly in development mode
✗ Incorrect
useEffect runs in the browser, but Server Components run only on the server.
How does data fetching work in Server Components?
AData is fetched on the server before rendering
BData is fetched after the page loads in the browser
CData fetching is not allowed
DData is fetched using client-side hooks
✗ Incorrect
Server Components fetch data on the server before sending HTML to the client.
What does the browser receive from a Server Component?
ANo content until client runs code
BRaw React code
COnly JavaScript
DFully rendered HTML
✗ Incorrect
The browser receives fully rendered HTML from Server Components for faster display.
Explain how the Server Component execution model works in Next.js and why it improves performance.
Think about where the code runs and what the browser receives.
You got /5 concepts.
Describe the limitations of Server Components regarding React hooks and client-side interactivity.
Consider what hooks need the browser environment.
You got /4 concepts.
Practice
(1/5)
1. What is the main purpose of a Next.js server component?
easy
A. To manage browser events like clicks and form submissions
B. To handle client-side user interactions and state updates
C. To run code only on the server and send pre-rendered HTML to the client
D. To load CSS styles dynamically on the client
Solution
Step 1: Understand server component role
Server components run only on the server and generate HTML before sending it to the browser.
Step 2: Compare with client components
Client components handle interactions and state, but server components focus on data fetching and static rendering.
Final Answer:
To run code only on the server and send pre-rendered HTML to the client -> Option C
Quick Check:
Server components = server-only rendering [OK]
Hint: Server components run on server, not browser [OK]
Common Mistakes:
Confusing server components with client components
Thinking server components handle user events
Assuming server components run in the browser
2. Which of the following is the correct way to define a Next.js server component?
easy
A. export default async function MyComponent() { return
Hello from server
}
B. 'use client';\nexport const runtime = 'edge'; export default function MyComponent() { return
Hello
}
C. 'use client';\nexport const dynamic = 'force-dynamic'; export default function MyComponent() { return
Hello
}
D. 'use client';\nexport default function MyComponent() { return
Hello
} // runs on client
Solution
Step 1: Identify server component syntax
Server components can be async functions that fetch data and return JSX.
Step 2: Check options for server component traits
export default async function MyComponent() { return <div>Hello from server</div> } exports an async function returning JSX, which is valid for server components.
Final Answer:
export default async function MyComponent() { return <div>Hello from server</div> } -> Option A
Quick Check:
Async function export = server component [OK]
Hint: Async function export usually means server component [OK]
Common Mistakes:
Assuming all exported functions run on client
Confusing runtime or dynamic exports with server component definition
Not using async when fetching data in server components
3. Given this Next.js server component code, what will be rendered in the browser?
export default async function Page() {
const data = await fetch('https://api.example.com/data').then(res => res.json())
return <div>Count: {data.count}</div>
}
medium
A. Client-side loading spinner until data arrives
B. An error because fetch is not allowed in server components
C. Empty div because data is undefined
D. <div>Count: 42</div> (assuming API returns { count: 42 })
Solution
Step 1: Understand server component data fetching
Server components can fetch data using await and render the result directly.
Step 2: Predict output with given API response
If API returns { count: 42 }, the component renders <div>Count: 42</div> as static HTML.
Final Answer:
<div>Count: 42</div> (assuming API returns { count: 42 }) -> Option D
Quick Check:
Server fetch + await = pre-rendered data [OK]
Hint: Server components fetch data before rendering [OK]
Common Mistakes:
Thinking fetch is disallowed in server components
Expecting client-side loading states in server components
Assuming data is undefined without awaiting fetch
4. Identify the error in this Next.js server component code:
export default function Page() {
const data = fetch('/api/data').then(res => res.json())
return <div>Data: {data.value}</div>
}
medium
A. Missing async/await causes data to be a Promise, not resolved value
B. fetch cannot be used inside server components
C. JSX syntax error in return statement
D. Using relative URL in fetch is not allowed on server
Solution
Step 1: Check fetch usage in server component
fetch returns a Promise; without await, data is a Promise object.
Step 2: Understand JSX rendering with Promise
JSX cannot render a Promise directly, causing incorrect output or error.
Final Answer:
Missing async/await causes data to be a Promise, not resolved value -> Option A
Quick Check:
Always await fetch in server components [OK]
Hint: Always await fetch to get data, not Promise [OK]
Common Mistakes:
Forgetting async keyword on function
Trying to render Promise instead of data
Assuming fetch is disallowed in server components
5. How can you combine server components with client components in Next.js to fetch data securely and handle user interactions?
hard
A. Fetch data inside client component and send it back to server component via props
B. Use a server component to fetch data and pass it as props to a client component for interaction
C. Use only client components for both data fetching and interactions
D. Use server components to handle user events and client components to fetch data
Solution
Step 1: Understand server and client component roles
Server components fetch data securely and prepare HTML; client components handle user events.
Step 2: Combine by passing data as props
Server component fetches data, then passes it to client component which manages interactions.
Final Answer:
Use a server component to fetch data and pass it as props to a client component for interaction -> Option B
Quick Check:
Server fetch + client interaction = Use a server component to fetch data and pass it as props to a client component for interaction [OK]
Hint: Server fetches data, client handles UI events [OK]
Common Mistakes:
Fetching data in client component only
Trying to handle user events in server components
Passing data from client to server component via props
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.