Only plain objects, and a few built-ins, can be passed to Client Components from Server Components
Answered
LaPerm posted this in #help-forum
LaPermOP
I build a DAO for carbon accounting. I have a trouble (https://github.com/vporton/carbon-flow_colony/tree/0d9d6a0687c963f709cacebedf43407b7dfa2bbd). Could you help as a more experienced Next.js developer?
Note that I do understand that server objects can't be passed to client. But where exactly they are passed?
$ yarn run build
...
[0] 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.
[0] at /home/porton/Projects/carbon-flow-colony/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:12:141840
[0] at Object.toJSON (/home/porton/Projects/carbon-flow-colony/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:12:143612)
[0] at stringify (<anonymous>)
[0] at eE (/home/porton/Projects/carbon-flow-colony/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:12:131997)
[0] at eR (/home/porton/Projects/carbon-flow-colony/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:12:132440)
[0] at Timeout._onTimeout (/home/porton/Projects/carbon-flow-colony/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:12:129220)
[0] at listOnTimeout (node:internal/timers:569:17)
[0] at process.processTimers (node:internal/timers:512:7)
...Note that I do understand that server objects can't be passed to client. But where exactly they are passed?
Answered by LaPerm
I've found the error: It was using
<QueryClientProvider> in server-side layout.5 Replies
LaPermOP
Every time when I need to update the DB, I create two "parts" of the code: backend API and frontend that calls the backend using
fetch. Is it possible to do it without having two separate pieces of code?You could use server actions
@joulev You could use server actions
LaPermOP
What is this?