# Server Component Payloads & Serialization

> The invisible data format that powers Server Components, and why functions can't cross the network.

Subject: Next.js | Lesson 4 of 65 | 6 min read
Interactive lesson: https://codewithanimation.in/nextjs/rsc-payloads
Previous: [Route Segments & Nested Routing](https://codewithanimation.in/nextjs/route-segments-nested.md) | Next: [The page.js Convention](https://codewithanimation.in/nextjs/page-file.md)

## What is the RSC Payload?

When a Server Component renders, it doesn't send HTML to the browser right away. First, it generates a special, compact data format known as the React Server Component (RSC) Payload.

This payload contains the structural 'blueprint' of the rendered Server Components, along with any props that need to be passed down to Client Components.

## The network boundary

In a traditional React app, all components live in the browser's memory, so they can freely pass anything to each other. In Next.js, Server Components live on the server, while Client Components run in the browser.

Between them lies a physical network boundary. The RSC Payload is the transport mechanism used to safely bridge this gap, sending only what the browser strictly needs to construct the UI.

## Serialization

When a Server Component renders a Client Component and passes it a prop, that prop must travel over the internet inside the RSC Payload.

To do this, Next.js must 'serialize' the data—convert it from a living JavaScript value in memory into a string of text that can be transmitted. When it reaches the browser, it is 'deserialized' back into a JavaScript value.

## Common mistake: The non-serializable prop error

The #1 error developers encounter when learning Server Components is trying to pass a function (like an `onClick` handler) from a Server Component to a Client Component.

You cannot serialize a JavaScript function over a network. The execution context, closures, and memory references are trapped on the server. If you attempt this, Next.js will crash with an error: 'Functions cannot be passed directly to Client Components unless you explicitly expose it by marking it with "use server".'

## Tip: Stick to plain data

When passing props across the Server-to-Client boundary, stick to plain, JSON-serializable data.

Strings, numbers, booleans, arrays, and plain JavaScript objects traverse the network perfectly. If a Client Component needs a function, define that function inside the Client Component itself.

## Try it: The Network Boundary

Try passing different types of props from the Server to the Client to see which ones survive serialization.

The animation is on the lesson page and is not part of this text version: https://codewithanimation.in/nextjs/rsc-payloads

## Check yourself

### Question 1

What is the primary purpose of the React Server Component (RSC) Payload?

- A. To send the raw JavaScript code of Server Components to the browser
- B. To replace standard HTML entirely
- C. To transmit the rendered UI structure and props from the server to the client
- D. To cache API responses

Correct answer: C

The RSC Payload is a streamable data format that contains the structure of the Server Components and the serialized props meant for Client Components.

- Why not A: The point of Server Components is that their JS is NEVER sent to the browser.
- Why not B: Next.js still generates HTML for initial load; the RSC Payload is used by React to hydrate and update the page.
- Why not D: While caching exists, the RSC Payload specifically transports the component tree.

### Question 2

Which of the following props will CAUSE A CRASH if passed from a Server Component to a Client Component?

- A. user={{ name: 'Alice', age: 25 }}
- B. isAdmin={true}
- C. tags={['react', 'nextjs']}
- D. onClick={() => console.log('Clicked')}

Correct answer: D

Standard JavaScript functions cannot be serialized across a network boundary. Attempting to pass one from a Server Component to a Client Component will cause a Next.js serialization error.

- Why not A: Plain objects serialize perfectly.
- Why not B: Booleans serialize perfectly.
- Why not C: Arrays serialize perfectly.

## Remember this

- The RSC Payload is the data bridge between Server Components and Client Components.
- Data passed from Server to Client must cross a physical network boundary.
- Props must be serialized to cross this boundary.
- Functions, class instances, and complex objects cannot be serialized. Stick to plain JSON data.
