Jack Vane
Jack Vane12mo ago

Convex Auth on the server?

I'm using Convex Auth, Convex Ents, and TanStack Start. I want to be able to take advantage of the beforeLoad method of each route to redirect unauthenticated users as it's wasteful and prone to security leaks if I rely sole on the Authenticated and Unathenticated components as people have been suggesting here. Now I get that sessions are managed in localstorage, and it's a tall order to validate that on the server (wouldn't be a problem if you used cookies instead), but is there a plan to be able to let us get the auth status of a user on the server? There's already a way to use Convex calls on the server, so surely there's a way to check if a user is authenticated or not?
4 Replies
jamwt
jamwt12mo ago
hi! on the server means in your convex functions? which server are you referring to?
ballingt
ballingt12mo ago
check out server side auth for Next.js, that sounds like the kind of thing you want here. https://labs.convex.dev/auth/authz/nextjs Support specifically for Tanstack Start is coming for this, a few other things have come up in the couple weeks that slowed progress on this.
Server-side authentication in Next.js 14 - Convex Auth
Authentication library for your Convex backend
Jack Vane
Jack VaneOP12mo ago
As in things like createServerFn and beforeLoad in TanStack Start. Good to know it'll be solved eventually, I'll see if I can come up with another hacky way of working with this
OllieJT
OllieJT3mo ago
Is this still in the pipeline? The TanstackStart docs for auth on the server seems to be lacking. Many places (like this) point to nextjs, which is frustrating.

Did you find this page helpful?