0
0
NextJSframework~5 mins

Fetch in server components in NextJS - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What is a server component in Next.js?
A server component is a React component that runs only on the server. It can fetch data directly and send fully rendered HTML to the client, improving performance and SEO.
Click to reveal answer
beginner
How do you fetch data inside a Next.js server component?
You use the standard fetch API directly inside the server component. Since it runs on the server, you can fetch data without worrying about client-side delays or exposing secrets.
Click to reveal answer
intermediate
Why is fetch in server components better for SEO?
Because the data is fetched and rendered on the server before sending the page to the browser, search engines see the full content immediately, improving SEO.
Click to reveal answer
intermediate
What happens if you use fetch inside a client component in Next.js?
The fetch runs in the browser, which can cause slower loading and expose API keys or sensitive data. Server components avoid this by fetching on the server.
Click to reveal answer
beginner
Can you use async/await with fetch in Next.js server components?
Yes, server components support async/await syntax, making it easy to write clear and readable code when fetching data.
Click to reveal answer
Where does fetch run when used inside a Next.js server component?
AOn the server
BIn the browser
CBoth server and browser
DNowhere, fetch is not allowed
Why is fetching data in server components good for SEO?
ABecause data is fetched after page loads
BBecause it hides data from search engines
CBecause it uses client-side JavaScript
DBecause data is fetched on the server and sent as HTML
Which syntax can you use to handle fetch calls in server components?
ACallbacks only
BPromises only
CAsync/await
DNone, fetch is synchronous
What is a risk of fetching data in client components?
ASlower loading and exposing secrets
BFaster loading and better SEO
CNo risk, it is always safe
DServer crashes
Which of these is true about Next.js server components?
AThey run only in the browser
BThey can fetch data securely on the server
CThey cannot fetch data
DThey require special fetch libraries
Explain how fetch works inside a Next.js server component and why it improves performance.
Think about where the code runs and what the user sees first.
You got /4 concepts.
    Describe the difference between fetching data in server components versus client components in Next.js.
    Consider speed, security, and search engine visibility.
    You got /4 concepts.