Go backend
Hi all,
I'm currently working on setting up authentication for both a web frontend (using TanStack Start) and a mobile app (Expo, though I haven't started on the mobile side yet). The project is set up as a Turborepo with shared TypeScript code, so ideally I can reuse the same auth instance across both platforms.
However, I'm using Go for the backend for various reasons, and I’ve run into two main issues:
Handling cookies in the Go middleware. I assume there’s a way to do this via the better-auth docs or possibly through a utility/helper package, but I haven’t found a clear example yet.
Connecting the Go backend to the handler used here:
https://www.better-auth.com/docs/integrations/tanstack#mount-the-handler
Is there a way to wire this up with my Go backend? Or is that handler expected to run in a TypeScript environment only?
Additionally, I’m could use Drizzle just for the auth-related database operations if it simplifies integration (personally sounds a bit weird).
But I’m unsure how I’d then handle auth on the Expo mobile app — any advice on that would also be appreciated.
TanStack Start Integration | Better Auth
Integrate Better Auth with TanStack Start.
1 Reply
I’ve been thinking of a possible solution, but I’m not sure if it’s a good approach or not.
Instead of using cookies, I’m considering using JWTs for authentication. Since I already have the token and a backend package handling JWTs, this should work fine.
The main concern is around the api/auth route, especially in the context of integrating with TanStack Start and Expo, as described here: https://www.better-auth.com/docs/integrations/tanstack#mount-the-handler.
One idea is to use Drizzle for managing the user auth tables and reuse the same api/auth endpoint for both the TanStack Start and Expo projects.
so it can perform the same CRUD operations
TanStack Start Integration | Better Auth
Integrate Better Auth with TanStack Start.