From the course: Master React 19 and Next.js 16 with Hands-On Projects and Real-World Applications

Unlock this course with a free trial

Join today to access over 25,200 courses taught by industry experts.

Passing data from server to client components

Passing data from server to client components

Hello and welcome. In this session, I'm going to guide you through a fundamental concept in Next.js 16, how to pass data from a server component to a client component. This is a crucial pattern for building modern, efficient web applications. You'll learn how to fetch data on the server, where it's fast and secure, and then hand that data over to a client component handle the user interface and interactivity. This approach helps you maintain a clean separation of concerns, keeping your server logic and client logic neatly organized. Let's start by looking at our initial setup in the Courses page. This is a server component, which is the default in the Next.js app router. The main component, Courses page, is also an async function. This is a key feature here. It allows you to use await at the top level to fetch data before the page even begins to render. I call await getCourses() to get our course data. In the JSX, I'm simply mapping over the courses array to render an unordered list…

Contents