tRPCttRPC
Powered by
Michael SchaufelbergerM
tRPCβ€’13mo agoβ€’
2 replies
Michael Schaufelberger

How to make prefetching/RSC suspense work with auth?

Hi πŸ‘‹

I'm using the rsc-rq-prefetch pattern in my project. It worked quite well - up until I added auth to my tRPC procedures.

During SSR a server error gets thrown because the useSuspenseQuery request fails (there's no auth because SSR does not use the request's context/headers https://github.com/vercel/next.js/discussions/60640).

I'm wondering if there's a workaround that allows prefetching on the server for auth-protected procedures.
Am I missing something obvious?

I've seen the rsc-links example... Maybe I could make use of this? There it seems the server can use the request headers in a procedure. But since it should be a prefetch (and if pending, should be streamed in later) I'm not sure how I can pass such a rsc-linked call to the client in a possible pending state.
tRPCJoin
Move Fast & Break Nothing. End-to-end typesafe APIs made easy.
5,015Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

`createCaller` and RSC - with next-auth
Liltripple_reidLLiltripple_reid / ❓-help
3y ago
`refetchOnWindowFocus` with RSC?
Jan HenningJJan Henning / ❓-help
3y ago
How to handle 500s from prefetching
JDJJD / ❓-help
5mo ago
How to pass through authentication header when using createTRPCProxyClient and RSC?
ianIian / ❓-help
3y ago