Data fetching in server components
📖 Scenario: You are building a simple Next.js app that shows a list of users fetched from an API. You will use server components to fetch the data on the server side and render it directly.
🎯 Goal: Create a Next.js server component that fetches user data from an API and displays the users' names in a list.
📋 What You'll Learn
Create a server component named
UsersListFetch data from
https://jsonplaceholder.typicode.com/usersStore the fetched data in a variable called
usersRender a list of user names inside an unordered list
<ul>Use
async and await for data fetchingExport the component as default
💡 Why This Matters
🌍 Real World
Fetching data on the server side improves performance and SEO by sending fully rendered pages to the browser. This is common in modern web apps.
💼 Career
Understanding server components and data fetching is essential for Next.js developers building fast, scalable web applications.
Progress0 / 4 steps