**Title: Resolving Next.js Error When Passing Data from Server to Client Components**
I am currently working with a Next.js application where I fetch data using an API and pass the response from a server component to a client component. However, I encountered an Next.js error indicating that only plain objects and a few built-ins can be passed from server to client components.
When I try to pass the companyQuote prop, I receive the following error:
Error: Only plain objects, and a few built-ins, can be passed to Client Components from Server Components. Classes or null prototypes are not supported.
Error: Only plain objects, and a few built-ins, can be passed to Client Components from Server Components. Classes or null prototypes are not supported.
A bad solution to get it to work is using
JSON.parse(JSON.stringify(companyQuote))
JSON.parse(JSON.stringify(companyQuote))
I have consider using a
Schema.Struct
Schema.Struct
instead but then I need creating separate types and decode functions, which seems cumbersome.