I switched to directly querying against
I switched to directly querying against the api routes (so it goes client http req -> vercel server -> convex http routes) which has improved speed, but it does not use the user table in my db (instead the one in the component) which is not ideal :/
5 Replies
when you say hitting convex http routes, what do you mean
or rather, what you mean is clear, but how are you going about it
Using the better auth client (
authClient.getSession()
) to hit the next js api routes, which as far as I can tell looking under the hood fwds those requests to the convex site routes.
interesting I just assumed authClient wouldn't work server side
so you're using the user from getSession to server render?
Oh yeah no, this is in the client, not on the server. This is ran for trying to get user data to display in the UI via a hook. Its just that this is much faster to get user data then the convex query for some reason. Nearly instant vs a very noticable loading time if I use this convex query:
Yeah the token is already there via cookies and no websockets involved, would be faster
Server rendering will get it going faster, you can use preloadQuery for that
Example: https://github.com/get-convex/better-auth/blob/642be72bc799c827042edac050c03acc48346f8a/examples/next/app/(auth)/dashboard/server/page.tsx#L22