Skip to content
>_VibeUnstuck

Only plain objects, and a few built-ins, can be passed to Client Components

Last verified:

The fix

Only plain objects, and a few built-ins, can be passed to Client Components from Server Components. Classes or null prototypes are not supported. Pass the fields the client renders. Do not pass a class instance.

  1. 1

    Pass the fields the client renders

    Do not pass the model. Copy the strings and numbers into a plain object. Convert a Decimal with toString() unless the UI is doing arithmetic, in which case pass a number you have already checked. A Date may be passed on current React. If the log says Date objects are not supported, call toISOString() and parse it in the client.

    const row = await prisma.todo.findUnique({ where: { id } });
    if (!row) return null;
    return (
      <TodoCard
        id={row.id}
        title={row.title}
        createdAt={row.createdAt.toISOString()}
      />
    );
  2. 2

    Do not spread a class into a fake plain object

    {...row} does not strip a nested Decimal or another class. Build the object from the fields you mean to send. JSON.parse(JSON.stringify(row)) drops undefined, turns Date into a string, and throws on a circular value. Use it only as a temporary look at the payload, not as the fix.

  3. 3

    Treat a Server Action argument the same way

    If the sentence says passed to Server Actions, the client called the action with a class or a null-prototype object. Send a plain object or FormData. Do not pass a Prisma client, a Decimal, or the result of Object.create(null).

  4. 4

    Do not mark the page use client to keep the class

    Moving the whole page to the client hides the boundary and pulls the data fetch with it. Keep the query in the Server Component. A function prop is the other serialization error, not this one.

Why it happens

Props from a Server Component to a Client Component are serialized. React accepts strings, numbers, booleans, null, undefined, bigint, plain objects and arrays, Date, Map, Set, typed arrays, promises of those, and Server Functions. It rejects a class instance and an object whose prototype is null. The throw is Only plain objects, and a few built-ins, can be passed to Client Components from Server Components. Classes or null prototypes are not supported. The next lines show the prop, often {} when the value has no enumerable fields.

A Prisma model, a Decimal, or any new SomeClass() is a class. Spreading it with {...row} copies enumerable data fields and still leaves nested class values in place. Object.create(null) is the null-prototype case. Passing the same value into a Server Action throws the sibling sentence, passed to Server Actions, for the same reason.

An older Next.js warning was Date objects are not supported under Only plain objects can be passed to Client Components from Server Components. Current React serializes Date. If the log still names Date objects, that app is on the old warning: pass toISOString(). On a current app, a Date is allowed, and this error is the class or the null prototype. Rendering a Date as a child is Objects are not valid as a React child, which is a different page.

The next error you'll probably hit

Once this is fixed, the usual follow-up is Functions cannot be passed directly to Client Components. Functions cannot be passed directly to Client Components unless you explicitly expose it by marking it with "use server". An onClick in a Server Component is the other sentence: Event handlers cannot be passed to Client Component props. Define UI handlers in the client file.

Prompt to paste back into your AI tool

Paste this above the error.

Next.js throws: Only plain objects, and a few built-ins, can be passed to Client Components from Server Components. Classes or null prototypes are not supported. If it says passed to Server Actions, or the older Date objects are not supported, quote that sentence. The prop it points at is:
<paste the lines under the error>

Do not add use client to the page. Do not pass the Prisma model or a class instance through. Do not JSON.parse(JSON.stringify()) as the permanent fix. Do not pass a function to get past this.

1. Name the value that is a class or a null-prototype object.
2. Pass a plain object of the fields the client renders. Convert Decimal with toString(). If the log still says Date objects are not supported, pass toISOString().
3. If this is a Server Action argument, send that same plain object or FormData.
4. Change only the pass site.

Common questions

+The log says Date objects are not supported. Do I still convert the Date?

Yes, on that app. That wording is the older warning. Pass toISOString() and construct a Date in the client if you need one. The current throw names classes or null prototypes, and a Date is allowed there.

+I spread the Prisma row and it still throws. Why?

A nested Decimal or another class is still in the object. Copy the fields you render and convert those class values. Spreading does not make them plain.

+Only plain objects can be passed to Server Actions. Same fix?

Same rule, other direction. The argument the browser sent is a class or a null-prototype object. Send a plain object or FormData. A function argument is the other page.

Related errors