Better Auth Session Not Loading in TanStack Router Application

I'm encountering an issue with Better Auth sessions in my TanStack Router application. The session data appears correctly in network responses, but it's not being loaded or accessible in my React components. Project Setup: Better Auth version: 1.1.21 TanStack Router for routing Setup: Custom SessionProvider + Better Auth client The Issue: When a user logs in, I can see the correct session data in the network tab response. However, when I try to access this data in my application, I get null. Here are my console logs: @app/dashboard:dev: null @app/dashboard:dev: Session in root route: missing @app/dashboard:dev: User from route context: null What I've Tried Confirmed the correct session data is visible in network responses Added debug logging throughout the fetch process Verified that cookies are being set correctly in the browser Confirmed Better Auth client configuration is correct Tried using initialUser in SessionProvider and also loading in useEffect Checked for any type mismatches between the Better Auth user data and my User interface Questions Why is authClient.getSession() returning null when the network request shows valid data? Is there something wrong with how I'm integrating Better Auth with TanStack Router? Are there any known issues with Better Auth 1.1.21 and session management? Should I be using a different approach to handle authentication with TanStack Router? GitHub Repository You can see my full implementation here: [GitHub Repository Link] Any help or insights would be greatly appreciated!
GitHub
GitHub - astronautfa/tanstack-forge: A modern, opinionated monorepo...
A modern, opinionated monorepo template for building lightning-fast, feature-rich single-page applications. - astronautfa/tanstack-forge
2 Replies
ali97
ali97OP4w ago
I went through and fixed the implementation. The commit is 'fixed sign in functionality' for anyone having the same problem in the future
bekacru
bekacru4w ago
Hey have you tried updating to latest? 1.2.5?

Did you find this page helpful?