Server Component reactivity
Hey all, I have a bit of a dumb question. If trying to use convex with server components in nexths you won't get the real-time update changes shown in the UI correct?
5 Replies
Another great answer from the docs AI chat:
Correct, currently when using Convex with server components in Next.js, the data won't be fully reactive. This is because Convex requires a connection from your deployment to the browser in order to push updates as data changes and this must happen on the client-side. If you load data from Convex on the server, it will be non-reactive. Convex is investigating ways to combine Next.js server-side rendering with end-to-end reactivity. So, stay tuned for updates on this.
Here are the relevant docs also: 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
Note also this part of that doc:
If you want to preload data from Convex and leverage Next.js server rendering, but still retain reactivity after the initial page load, use preloadQuery from convex/nextjs.(i don't know why the docs chat doesn't know about this... 😕 )
Oh preloadQuery works with server components, nice!
Thx all 🙂
I love the support from you guys , always incredibly helpful!