Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4072 pages
Next.js and React

Next.js: only plain objects can be passed to Client Components

ErrorOnly plain objects, and a few built-ins, can be passed to Client Components from Server Components. Classes or null prototypes are not supported.

Short answer

Props from a Server Component to a Client Component must be serializable. Class instances, objects with a null prototype, and plain functions are not. Convert the value to a plain object before passing it, or call the function inside the Client Component. Database rows and SDK responses are the usual culprits.

  • Applies to Next.js 15, Next.js 16, React 19
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Fix it fast

  1. 1Find out which cause you have

    Find the Server Component that renders the Client Component and log what you pass. Note whether the value is a class instance, comes from an ORM, or has a null prototype.

    console.log(Object.getPrototypeOf(value), value?.constructor?.name)
  2. 2Match what you see, then jump to its fix

    1. 1The error names the prop, and the value comes from a database or API clientA class instance (ORM model, SDK result) is passed as a propFix
    2. 2Value came from Object.create(null) or a library that builds objects that way (query strings, some parsers)The object was created with a null prototypeFix
    3. 3The prop is a callback or a helper defined in the Server ComponentA function that is not a Server Function is passed as a propFix

What does the error look like?

  • Only plain objects, and a few built-ins, can be passed to Client Components from Server Components. Classes or null prototypes are not supported.

Cause 1 of 3

A class instance (ORM model, SDK result) is passed as a prop

1Check

Per React, objects that are instances of any class other than the built-ins are not supported. Inspect the constructor name.

console.log(value?.constructor?.name)  // anything except Object or a built-in is a problem

2Fix

Copy it into a plain object, keeping only the fields the Client Component needs.

// Server Component
const user = await db.user.findUnique({ where: { id } })
const plain = { id: user.id, name: user.name, createdAt: user.createdAt }
return <Profile user={plain} />

3Verify

Reload the page; the error should be gone.

npm run dev

Confirmed by react.dev

Did this fix it?

Cause 2 of 3

The object was created with a null prototype

1Check

Check the prototype of the value.

console.log(Object.getPrototypeOf(value) === null)

2Fix

Spread it into a normal object literal.

const plain = { ...value }

3Verify

Render the Client Component again.

npm run dev

Confirmed by react.dev

Did this fix it?

Cause 3 of 3

A function that is not a Server Function is passed as a prop

1Check

Functions can cross the boundary only if they are Server Functions or exported from a client-marked module.

grep -rn "use server\|use client" app | head

2Fix

Define the handler inside the Client Component, or make a Server Function with 'use server'.

// actions.ts
'use server'
export async function save(formData: FormData) { /* ... */ }

3Verify

Pass the action as a prop and run it from the client.

npm run dev

Confirmed by react.dev

Did this fix it?

How do I stop it coming back?

  • Map database and SDK results to plain objects at the data layer before they reach components.
  • Pass only the fields the Client Component displays.
  • Add the 'server-only' package to data modules so they are never imported by client code.

Sources

How was this page made?

I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.

Which stack is behind this page?

Projects of mine built on the same technologies:

Related fixes

Web apps

next/link throws React.Children.only on its children

Error: React.Children.only expected to receive a single React element child.

React.Children.only accepts exactly one React element and throws for anything else, including an array with one item.

3 causes, each with a fix

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.