vector
vector12mo ago

Next on Convex

so whats the point of a next js convex stack\
12 Replies
erquhart
erquhart12mo ago
Not sure I follow, you use client for some things, server for others. If all of your app’s code can run in the browser and you don’t need a database, you may not need convex. But that’s pretty unlikely to be the case with any app. You’ll need authentication, user data, application data, protected logic that needs to run on the server, etc. This is true no matter what framework or static site generator you’re using. Not specific to Next.
vector
vectorOP12mo ago
yeah whats the benefit of using next js with convex if convex can handle all the server side items? do real time queries even work with SSR? yeah im referring to apps that use convex as a backend to handle auth, data, etc
lee
lee12mo ago
Convex News
Announcing Convex 1.8
Happy New Year! At Convex we’re kicking the year off with another release! Highlights: * New simpler API for loading and preloading data from Convex in Next.js server-side * Team usage breakdown by function on dashboard convex/nextjs for Next.js A new entrypoint in the convex package provides an
erquhart
erquhart12mo ago
Ah I see what you mean - the only tough part is specifically using Server Components, where Convex data isn’t reactive. As you can see in the announcement Lee linked, preloadQuery can now be used server side data fetching while retaining reactivity.
TwendyKirn
TwendyKirn12mo ago
Hey, just wanted to double check - we won't have reactivity if we are using preloadQuery on the server components?
erquhart
erquhart12mo ago
preloadQuery does retain reactivity
TwendyKirn
TwendyKirn12mo ago
Yap, sorry, just read your previous message again and noticed the end) I was just confused because I read docs (which you sent) but I think message didn't mention it🫣
erquhart
erquhart12mo ago
No problem! It’s a bit confusing seeing the preloadQuery docs followed by server component docs that say server component fetching is not reactive, but that section is speaking to fetching without preloading queries.
TwendyKirn
TwendyKirn12mo ago
I have one more question which is might be very dummy but still (sorry for stealing this thread for own questions) - in the docs it says that fetchQuery/fetchMutation and etc using HTTP client under the hood, will those calls calculated as queries/mutations inside pricing plan or as actions? Because if you want to create HTTP api with Convex - you need to use actions (as far as I understood) and not queries, so I was always confused with that moment inside docs for server components. I'm just curios because in my case the app has client portal and own http api (all based on Convex), so I would assume that if Convex calculates server fetches as http actions - it would be better for me to use as much client components as possible in order to save money (so that way web portal can use queries limit and api can use actions hours) But again, might dummy topic, sorry about that.
lee
lee12mo ago
yeah sorry there are two things called HTTP so it's a bit confusing. fetchQuery and fetchMutation use the built-in http api for functions https://docs.convex.dev/http-api/ which is in contrast to the Websocket api used by useQuery/useMutation in React. HTTP actions https://docs.convex.dev/functions/http-actions are separate, have different pricing, and you are only using them if you have an http.js/http.ts file and are using the .convex.site url.
Convex HTTP API | Convex Developer Hub
Connecting to Convex directly with HTTP
HTTP Actions | Convex Developer Hub
HTTP actions allow you to build an HTTP API right in Convex!
TwendyKirn
TwendyKirn12mo ago
Thank you!

Did you find this page helpful?