Recall & Review
beginner
What is a key restriction of Next.js Server Components regarding browser APIs?
Server Components cannot use browser-only APIs like
window, document, or localStorage because they run on the server, not in the browser.Click to reveal answer
beginner
Can Server Components in Next.js use React hooks like
useState or useEffect?No, Server Components cannot use client-only React hooks such as
useState or useEffect because they do not run in the browser and have no state or lifecycle.Click to reveal answer
intermediate
Why can't Server Components import client components directly in Next.js?Server Components can import client components, but client components must be marked with <code>"use client"</code>. This keeps server and client code separate.Click to reveal answer
beginner
What kind of data fetching is recommended inside Next.js Server Components?
Server Components can fetch data directly using async/await because they run on the server, allowing secure and fast data fetching without exposing secrets to the client.
Click to reveal answer
beginner
Explain why Server Components cannot have event handlers like
onClick.Event handlers like
onClick require client-side JavaScript to run. Server Components render HTML on the server and do not handle client events, so event handlers must be in Client Components.Click to reveal answer
Which of the following is NOT allowed inside a Next.js Server Component?
✗ Incorrect
Server Components run on the server and cannot access browser-only objects like
window.Can you use React's
useState hook inside a Server Component?✗ Incorrect
useState is a client-side hook and cannot be used in Server Components.How do you mark a component as a Client Component in Next.js?
✗ Incorrect
Adding
"use client" at the top tells Next.js this component runs on the client.Why can't Server Components handle user events like clicks?
✗ Incorrect
Server Components do not run in the browser, so they cannot handle client-side events.
Which is a benefit of Server Components in Next.js?
✗ Incorrect
Server Components run on the server, so they can fetch data securely without exposing secrets.
Describe the main restrictions of Next.js Server Components and why they exist.
Think about where Server Components run and what that means for code they can use.
You got /5 concepts.
Explain how Server Components and Client Components work together in Next.js.
Consider the roles of server and client in a web app.
You got /5 concepts.