| | |

React Server Components 15 🧬 Serialization Constraints — What can and cannot cross to the client

⏱️ Estimated read: 10 min | |

The boundary between a Server Component and a Client Component is a serialization boundary. When a Server Component renders a Client Component, the props are not passed by reference; they are serialized into the RSC Payload, sent over the network, and deserialized on the client. This means every prop must be representable in a format that both environments can understand. A plain object crosses. A class instance does not. A string crosses. A function does not, unless it is a Server Function marked with 'use server' .

This chapter covers the complete list of serializable and non-serializable types, the specific failures that occur when a non-serializable value is passed, and the conversion patterns that turn a non-serializable value into a serializable one.

Key point: The boundary enforces a subset of JavaScript values. Primitives, plain objects, arrays, Date, Map, Set, TypedArray, ArrayBuffer, globally registered symbols, Promises, JSX elements, and Server Functions are serializable. Class instances, plain functions, unregistered symbols, and WeakMap/WeakSet are not.


Why the boundary is restrictive

The transport problem. The RSC Payload is a serialized representation of the React tree. It cannot carry a live reference to a function in the server’s memory, because the client has no access to that memory. It cannot carry a class instance with methods, because the methods are not serializable and the prototype chain would be lost. The format supports a specific set of types, and everything else fails at the boundary .

The DevTools problem. Even if a non-serializable value could be forced through, the developer tools would display it as an empty object or crash. The serialization boundary is not just a React constraint; it is the contract that makes the tree inspectable, cacheable, and streamable.

The security problem. A class instance can carry more than the data it exposes. A Mongoose document, for example, has internal state and methods that should not reach the client. The serialization boundary forces the developer to extract the plain data and pass only that .


a. The serializable types

The React documentation lists the supported types for props and for Server Function arguments. The list is the same for both contexts .

Primitives—string, number, bigint, boolean, undefined, null—are serializable. A globally registered symbol (Symbol.for('key')) is serializable; an unregistered symbol is not .

Iterables containing serializable values are serializable: Array, Map, Set, TypedArray, ArrayBuffer. A Date is serializable. FormData is serializable as a Server Function argument .

Plain objects are serializable if every property is serializable. A plain object is one created with an object literal or Object.create(null); an instance of a class is not a plain object, even if it has the same properties .

Promises are serializable. A Server Component can pass an unresolved Promise to a Client Component, and the Client Component can read it with use() .

React elements, or JSX, are serializable as props. A Server Component can pass a rendered element to a Client Component, and the Client Component renders it as children .

Server Functions are serializable. A function marked with 'use server' is passed as a reference, not as code. The client receives a placeholder that, when called, sends a network request to the server .


b. The non-serializable types

The non-serializable types are the ones that fail at the boundary.

Plain functions are not serializable. An event handler like onClick={() => {}} passed from a Server Component to a Client Component fails. The Client Component must define its own handler, or receive a Server Function .

Class instances are not serializable. A new URL(), a new Intl.NumberFormat(), a custom class User, and a Mongoose document are all class instances. They fail because the class prototype and methods cannot be serialized .

Unregistered symbols are not serializable. Symbol('my symbol') fails. Symbol.for('my symbol') succeeds because it is registered in the global symbol registry .

WeakMap and WeakSet are not serializable. They are not iterable and do not expose their contents .

Objects with a null prototype are not serializable. A plain object created with Object.create(null) fails, even though an object literal succeeds .


c. The conversion patterns

The fix for a non-serializable value is to convert it to a serializable one before it crosses the boundary.

A Date is already serializable, so no conversion is needed. A class instance like new URL() must be converted to its string representation: { url: myUrl.toString() } . A Map is serializable, but if the client needs an array, Array.from(map) is the conversion. A Set is serializable, but [...set] produces an array.

A plain function cannot be converted. It must be replaced with a Server Function if the client needs to call server logic, or with a handler defined inside the Client Component if the logic is purely client-side .

A Mongoose document or a database row object must be converted to a plain object containing only the fields the client needs. Passing the full document leaks internal state and fails the serialization check .


Complete Example Session

// ============================================
// PART 1: A SERIALIZABLE PROP
// ============================================
<ClientComponent
  id="1"
  title="Hello"
  tags={['a', 'b']}
  createdAt={new Date()}
/>
// All serializable.
// ============================================
// PART 2: A NON-SERIALIZABLE FUNCTION
// ============================================
<ClientComponent onClick={() => {}} /> // ❌
// Functions are not serializable.
// ============================================
// PART 3: THE SERVER FUNCTION FIX
// ============================================
// app/actions.ts
'use server'
export async function handleClick() { /* ... */ }

// app/page.tsx
<ClientComponent onClick={handleClick} /> // ✅
// Server Functions are serializable as references.
// ============================================
// PART 4: A NON-SERIALIZABLE CLASS INSTANCE
// ============================================
<ClientComponent url={new URL('https://example.com')} /> // ❌
// ============================================
// PART 5: THE STRING CONVERSION FIX
// ============================================
<ClientComponent url={new URL('https://example.com').toString()} /> // ✅
// ============================================
// PART 6: A DATABASE DOCUMENT
// ============================================
const user = await db.user.findUnique({ where: { id } })
<ClientComponent user={user} /> // ❌ (Mongoose document)

// Convert to plain object
<ClientComponent user={{ id: user.id, name: user.name }} /> // ✅
// ============================================
// PART 7: A MAP PROP
// ============================================
<ClientComponent cache={new Map([['a', 1]])} /> // ✅
// Map is serializable.
// ============================================
// PART 8: A PROMISE PROP
// ============================================
const promise = getData()
<ClientComponent data={promise} /> // ✅
// The client reads it with use().
// ============================================
// PART 9: A JSX CHILD
// ============================================
<ClientWrapper>
  <ServerContent /> {/* ✅ JSX is serializable */}
</ClientWrapper>
// ============================================
// PART 10: THE DECISION TREE
// ============================================
// Is it a primitive, plain object, or array? → pass it
// Is it a Date, Map, Set, TypedArray? → pass it
// Is it a class instance? → convert to plain object or string
// Is it a function? → use a Server Function or define in client
// Is it a Promise? → pass it, read with use()
// Is it JSX? → pass it as children

The ten parts covered the serializable prop, the function failure, the Server Function fix, the class instance failure, the string conversion, the database document conversion, the Map prop, the Promise prop, the JSX child, and the decision tree.


Quick Reference

Serializable types

TypeDetail
Primitivesstring, number, bigint, boolean, undefined, null
Globally registered symbolsSymbol.for('key')
Plain objectsObject literals with serializable values
ArraysContaining serializable values
DateYes
Map, SetYes
TypedArray, ArrayBufferYes
FormDataYes (Server Function arguments)
PromisesYes, read with use()
JSX elementsYes, pass as children
Server FunctionsYes, 'use server' reference

Non-serializable types

TypeReason
Plain functionsNot representable
Class instancesPrototype and methods lost
Unregistered symbolsNot globally registered
WeakMap, WeakSetNot iterable
Objects with null prototypeNot plain objects
Events from handlersNot serializable

Conversion patterns

Non-serializableSerializable replacement
new URL().toString()
Class instancePlain object with needed fields
Database documentPlain object with needed fields
Event handlerServer Function or client-defined handler
Map (if array needed)Array.from(map)
Set (if array needed)[...set]

Server Function arguments

TypeSupported
PrimitivesYes
DateYes
Map, SetYes
FormDataYes
Plain objectsYes
Server FunctionsYes
React elementsNo
Plain functionsNo
ClassesNo
Unregistered symbolsNo

Best Practices

✅ Do This:

// Convert a URL to a string
<Client url={url.toString()} />                              // ✅
// Convert a database document to a plain object
<Client user={{ id: user.id, name: user.name }} />           // ✅
// Use a Server Function for callable behavior
<Client onClick={serverAction} />                            // ✅
// Pass JSX as children
<ClientWrapper><ServerContent /></ClientWrapper>             // ✅

❌ Don’t Do This:

// Pass a plain function
<Client onClick={() => {}} />                                // ❌
// Pass a class instance
<Client url={new URL('https://example.com')} />              // ❌
// Pass a Mongoose document
<Client user={mongooseDoc} />                                // ❌
// Pass an unregistered symbol
<Client symbol={Symbol('key')} />                            // ❌

Common Pitfalls

PitfallWhy It HappensFix
Functions cannot be passedPlain function propUse a Server Function or client handler
URL is not serializableClass instance.toString()
Mongoose document is not serializableClass instance with internal stateConvert to plain object
Symbol is not serializableUnregistered symbolUse Symbol.for()
Map is not serializableOlder React versionCheck the React version; Map is supported in current versions
Promise is not serializablePassing a resolved value instead of the PromisePass the Promise and read with use()

Real-World Examples

1. Serializable primitive

<Client id="1" />

2. Serializable array

<Client tags={['a', 'b']} />

3. Serializable Date

<Client createdAt={new Date()} />

4. Serializable Promise

<Client data={getData()} />

5. Serializable JSX

<Client>{<ServerContent />}</Client>

6. Server Function

'use server'
export async function save() { ... }
<Client onSave={save} />

7. URL conversion

<Client url={url.toString()} />

8. Document conversion

<Client user={{ id: user.id, name: user.name }} />

9. The error

Functions cannot be passed directly to Client Components.

10. The decision

Plain value? → pass
Class instance? → convert
Function? → Server Function or client handler

Visual

The serialization boundary

┌─────────────────────────────────────────────────────────────┐
│  SERVER COMPONENT                                            │
│    <Client prop={value} />                                   │
│       │                                                      │
│       ▼                                                      │
│  Serialization check                                         │
│       │                                                      │
│       ├── serializable ──► RSC Payload ──► client            │
│       │                                                      │
│       └── non-serializable ──► error                         │
└─────────────────────────────────────────────────────────────┘

The serializable types

┌─────────────────────────────────────────────────────────────┐
│  ✅ Primitives        ✅ Plain objects                       │
│  ✅ Arrays            ✅ Date                                │
│  ✅ Map, Set          ✅ TypedArray, ArrayBuffer             │
│  ✅ Promises          ✅ JSX elements                        │
│  ✅ Server Functions                                        │
└─────────────────────────────────────────────────────────────┘

The non-serializable types

┌─────────────────────────────────────────────────────────────┐
│  ❌ Plain functions   ❌ Class instances                     │
│  ❌ Unregistered symbols  ❌ WeakMap, WeakSet                │
│  ❌ Null-prototype objects                                  │
└─────────────────────────────────────────────────────────────┘

The conversion

┌─────────────────────────────────────────────────────────────┐
│  new URL('...') ──► .toString()                              │
│  mongooseDoc ──► { id, name }                                │
│  onClick={() => {}} ──► 'use server' function               │
│  Symbol('x') ──► Symbol.for('x')                             │
└─────────────────────────────────────────────────────────────┘

Summary

ItemValue
BoundaryServer Component to Client Component
MechanismSerialization into RSC Payload
SerializablePrimitives, plain objects, arrays, Date, Map, Set, Promise, JSX, Server Functions
Non-serializableFunctions, class instances, unregistered symbols, WeakMap/WeakSet
ConversionClass instance → plain object or string
Function replacementServer Function or client handler
Server Function argumentsSame serializable types
JSXSerializable as children

Key takeaways:

  • The boundary enforces a specific serialization contract. Props passed from a Server Component to a Client Component must be serializable into the RSC Payload. The contract is defined by React, and it is narrower than JavaScript’s type system .
  • Plain functions are not serializable. An event handler cannot cross from server to client. The Client Component must define its own handler, or receive a Server Function marked with 'use server' .
  • Class instances are not serializable. A URL, a Date wrapper, a custom class, or a Mongoose document fails. Convert it to a plain object or a string before passing it .
  • The same rules apply to Server Function arguments and return values. A Server Function is called over the network, so its arguments and its return value must be serializable. React elements and plain functions are not supported as Server Function arguments .
  • Promises and JSX are serializable. A Server Component can pass an unresolved Promise to a Client Component, which reads it with use(). A Server Component can pass rendered JSX as children to a Client Component .
  • The conversion is the fix. A class instance becomes a plain object with the needed fields. A function becomes a Server Function or a client-defined handler. A symbol becomes a globally registered one. The error message points at the prop, and the conversion is the remedy.

Remember: The serialization boundary is the contract between the server and the client. Everything that crosses must be representable in the RSC Payload. Primitives, plain objects, arrays, Date, Map, Set, Promise, JSX, and Server Functions cross. Functions, class instances, and unregistered symbols do not. Convert the non-serializable value before it crosses, or move the logic into the Client Component. The boundary is not a limitation; it is what makes the tree streamable, inspectable, and safe.

Was this helpful?


Stop using slow, ad-bloated tool sites! 🤮

🔎 Search “KandZ Tools” on Google to use many professional utilities for free.

KandZ.me is the ultimate minimalist hub for:
✅ Finance (Mortgage, Interest, Inflation)
✅ Tech (Base64, JSON, Dev Suite, IP)
✅ Health (BMI, BMR, TDEE)
✅ Productivity (Timer, Workspace, QR)

⚡️ Fast & Private
🔒 No data leaves your device
💎 100% Free

🔗 Use it now: https://tools.kandz.me
🔖 Bookmark it—you’ll need it later!