Ragpud
Ragpud4w ago

Server side fetching and auth strategies

I'm basically prefetching everything in the server components in next then passing it to client components. This means though that auth has to be done in the server components because if I'm right in thinking clerk can't authenticate queries that aren't from the client?
Is there any benefit in fetching on the backend and passing to client components, I "think" it's supposed to be faster right? What I'm doing: Server component checks auth with clerk's useAuth hool, then preloads the data using convex's preloadQuery, passes it to a client component that uses usePreloadedQuery & using the loading.tsx files in next to display a loader.
Is this a good approach?
3 Replies
Convex Bot
Convex Bot4w ago
Thanks for posting in <#1088161997662724167>. Reminder: If you have a Convex Pro account, use the Convex Dashboard to file support tickets. - Provide context: What are you trying to achieve, what is the end-user interaction, what are you seeing? (full error message, command output, etc.) - Use search.convex.dev to search Docs, Stack, and Discord all at once. - Additionally, you can post your questions in the Convex Community's <#1228095053885476985> channel to receive a response from AI. - Avoid tagging staff unless specifically instructed. Thank you!
erquhart
erquhart4w ago
Next.js Server Rendering | Convex Developer Hub
Next.js automatically renders both Client and Server Components on the server
erquhart
erquhart4w ago
Whether server rendering is faster or better is a subject of debate, but it is supported.

Did you find this page helpful?