DaReal
DaReal6mo ago

Convex Queries In Server Components

I have a route ("/users/[userId]") and i want to fetch user info from the database by using the Convex query hook "useQuery" and also supply the data through a global state using zustand to child routes. However, i can only use the Convex hook in a client component. How do you suggest i implement this because i dont want to make the whole layout a client component.
2 Replies
erquhart
erquhart6mo ago
I believe you'll want to use fetchQuery. Check out the guide for Nextjs server rendering with Convex: https://docs.convex.dev/client/react/nextjs/server-rendering#using-convex-to-render-server-components
Next.js Server Rendering | Convex Developer Hub
Next.js automatically renders both Client and Server Components on the server
DaReal
DaRealOP6mo ago
Thanks.

Did you find this page helpful?