Open oalexdoda opened 1 month ago
You should only get that if you try to import registerApolloClient
from a Client Component, and it seems that this happens in a SSR step, which would indicate a Client Component.
I see that you do a server-only
import at the top of the file, which should prevent that, but could you please double-check your import paths? Does any client component directly or indirectly import this? (Look out for barrel files!)
I had to pass the use server directive in that file for the import to work and it no longer crashes.
but it does cause a type error here
it builds/works in dev, but not sure if that's how it's supposed to be.
here's the index.ts that exports things (this is all in a transpiled next.js package)
and how it gets exported in the package.json
not sure if any of this helps, but trying to give you some context of how it's used
Yeah, you definitely shouldn't use the "use server", it turns everything there into server functions, not server components.
I assume that your index.ts
here is the problem - if you import anything from a barrel file like that into a "use client"
file, that turns everything there into "client side" code, which will then crash, even if it was only meant for the server and never for the client.
I'm afraid, but with RSC/Next.js you can't use barrel files like that - you either have to create a index.rsc.js
and index.cc.js
(or similar), or - probably even better for your bundle size - stop using barrel files altogether.
Got it, that makes perfect sense - thanks a lot @phryneas !
Hi,
It looks like
@apollo/experimental-nextjs-app-support
is throwing an error where it can't findregisterApolloClient
.Not sure if it's because of it importing from
index.ssr.js
vs. another file, or what I'm doing wrong.Would appreciate some help!
Thanks!
Code:
Server Error: