Lots of trouble around the Authentication with start
Hi guys, I'm trying to add oauth authentication to my app and its very constraint. I've seen a lot of people struggling with the authentication
Basically the only way seems to use a server function with
useSession
in the router and propagate the authentication state in the router context.
As the router need to work in the server for first rendering, all typicals way to provide authentication (using local storage and /or a react AuthProvider) are not supported.
And the only way have several flaws:
- I was quickly blocked by the max session size (which is undocumented). As the session is stored in a cookie, it's limited to 4096 caracters. I can't put an id_token and a refresh_token in my session !
- the server function is constantly called, so some cache must be added. It adds complexity and error risks.
I think the authentication process needs to be rethink or at least some workaround correctly documented if Tanstack Start want to be largely used.
Did someone succeed to use a classical oauth authentication (with idToken, access token and refresh token) in Tanstack Start ?1 Reply
ugly-tan•4mo ago
Can't you just set cookies yourself instead of relying on useAppSession? You can use
setCookie
function to set cookies from your server functions, and use getCookie
to get cookies when needed.