T
TanStack6mo ago
like-gold

OAuth implementation

Has any already accomplished a next-auth like generic oauth implementation without using better-auth. Haven’t saw any demo/tutorial version doing that.
3 Replies
correct-apricot
correct-apricot6mo ago
I implemented a basic open id connect protocol using the useSession hook from h3 similar to the DIY auth example and it worked great. All the access tokens are stored in an encrypted http only cookie in the client and can be cleared with session.clear(). https://tanstack.com/start/latest/docs/framework/react/examples/start-basic-auth provides the useSession example and aside from that you’ll just need a backend server function to make the request to set the access token in the session
React TanStack Start Start Basic Auth Example | TanStack Start Docs
An example showing how to implement Start Basic Auth in React using TanStack Start.
like-gold
like-goldOP6mo ago
Thanks was already thinking about that but wanted to know if there are already packages around! Do you also store the refresh/id token in the session?
correct-apricot
correct-apricot6mo ago
Yes all of that data gets stored in the session. You'll have to implement your own refresh token logic (I haven't found any library that handles that automatically anyway.) This thread here might provide some insight as well: https://discord.com/channels/719702312431386674/1340316720442642452

Did you find this page helpful?