openapi-typescript icon indicating copy to clipboard operation
openapi-typescript copied to clipboard

Library-generated Promises cannot be passed down to Next.js Client Components as props, triggering error

Open rubin-alldev opened this issue 8 months ago • 0 comments

openapi-fetch version

0.13.4

Description

Hi there. I appreciate this lib very much, it has enabled me to bootstrap numerous APIs with ease and saved a lot of time.

Now I am trying to use it in a Next.js (v.14) project, but encountered a problem: promises, returned from the API client calls, can't be accepted as props to the underlying Client Components, triggering the following 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". At the same time, Promises obtained from the equivalent fetch calls go through successfully.

I'd like to know whether I've overlook something in the docs stating this limitation, or this may be fixed.

Reproduction

https://codesandbox.io/p/devbox/vy37yx (swap client call for fetch call in page.tsx to remove the error)

Expected result

Promise from the lib is correctly passed down to the Client Component

Extra

rubin-alldev avatar Mar 04 '25 11:03 rubin-alldev