← All errors · Next.js

Objects are not valid as a React child

Exact error

Error: Objects are not valid as a React child (found: object with keys {id, name}). If you meant to render a collection of children, use an array instead.

What it means

JSX tried to render a plain object. React can render strings, numbers, elements and arrays, but not objects.

Likely causes

How to fix it

  1. Render a specific field or convert to a string:

    <p>{user.name}</p>
    <p>{date.toLocaleDateString()}</p>
    <pre>{JSON.stringify(data, null, 2)}</pre>
  2. In client components, make sure you are not rendering a Promise from an un-awaited async call.

Related errors

Get new fixes weekly

No spam. Unsubscribe anytime. Privacy