RagpudR
Convex Community9mo ago
3 replies
Ragpud

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?
Was this page helpful?