React & Next.js errors · Error 06 of 7

“Objects are not valid as a React child”

By Muhammad Abdullah, full-stack, mobile and ai automation developer · Last reviewed

Objects are not valid as a React child (found: object with keys {…})

Short answer

You are rendering a whole object (or a Date, or a Promise) in JSX. Render a specific field, format the value as a string, or map an array to elements.

Common causes

  • Rendering an API response object directly, e.g. {user} instead of {user.name}.
  • Rendering a Date object, or an async function’s Promise.

How to fix it

  1. Render a field or a formatted string:

                          <p>{user.name}</p>
    <p>{createdAt.toLocaleDateString()}</p>
                        
  2. While debugging, inspect the value with JSON.stringify(value, null, 2).

Let’s talk about the next step

Have an idea, a stuck app, or a workflow toimprove?

Tell me what you are building, what is blocking you, and what a successful outcome looks like.