Yahya
BABetter Auth
•Created by Yahya on 3/28/2025 in #help
Tanstack Start Server functions cookie issue

26 replies
BABetter Auth
•Created by Yahya on 3/28/2025 in #help
Tanstack Start Server functions cookie issue
it does actually work, so the plugin is working just fine or we don't even need it? will have to test on my original setup, but this is very helpful
26 replies
BABetter Auth
•Created by Yahya on 3/28/2025 in #help
Tanstack Start Server functions cookie issue
the cookies work fine with the authClient, but using the auth api object in server functions i think doesn't work, just like next.js which is why I thought of creating a plugin like nextCookies() in the first place
26 replies
BABetter Auth
•Created by Yahya on 3/28/2025 in #help
Tanstack Start Server functions cookie issue
@gib so basically when the signIn() function from the authClient finishes, it sets a cookie session_data. I delete the cookie manually, I refresh the page to invoke my custom useSession() hook (which uses the auth api instance in a tanstack server function) and normally, it should add the cookie back after I deleted it because of my plugin.
this is the exact behavior happening in dev server, but it fails to add back the cookie in vercel or netlify.
are you sure it works?
26 replies
BABetter Auth
•Created by Yahya on 3/28/2025 in #help
Tanstack Start Server functions cookie issue
thanks a lot!
26 replies
BABetter Auth
•Created by Yahya on 3/28/2025 in #help
Tanstack Start Server functions cookie issue
let me know if you have any ideas on how to improve/fix this
26 replies
BABetter Auth
•Created by Yahya on 3/28/2025 in #help
Tanstack Start Server functions cookie issue
@gib here i created a repo for you https://github.com/yahyazgour/tanstack-start-better-auth
i've included .env.example, I disabled tanstack query caching, I delayed getSession() server function by 2seconds, and I enabled better auth cookie cache, and my plugin tanstackStartCookies().
You will see in dev server, the session_data cookie gets added back on every page refresh (Set-Coookie header available), after you manually delete it.
But when you deploy this to either Vercel or Netlify, the plugin doesn't work.
@Benfa @daveycodez maybe you want to check this out as well
26 replies
BABetter Auth
•Created by Yahya on 3/28/2025 in #help
Tanstack Start Server functions cookie issue
hi @Benfa , unfortunetly I still haven't figured it out, the plugin works for dev environement but not on deployment. If you want the cookies to work you can use api routes, but so far for server actions it seems the same issue as next.js is happening. looking forward to hear any ideas to improve this.
@daveycodez sure i'll ping you if I ever fix it
26 replies
BABetter Auth
•Created by Yahya on 1/31/2025 in #help
Better Auth X Jstack integration
I used singelton pattern for db and auth definition. I'm not sure if they should be defined inside index.js insead of a middleware.
I would also love any ideas about improving the auth router since all the auth procedures use better auth handler()
13 replies
BABetter Auth
•Created by Yahya on 1/31/2025 in #help
Better Auth X Jstack integration
That's what I ended up doing, removed db and auth from nextjs server, defined both inside a hono jstack middlware. I created a procedure for each better auth endpoint inside the auth router.
https://github.com/yahyazgour/jstack-betterauth in case you want to check, thanks for the insight man!
13 replies
BABetter Auth
•Created by Yahya on 1/31/2025 in #help
Better Auth X Jstack integration
@Rakesh yes that's the thing, so i'm guessing a /api/auth/ catch all route for better auth handler, which is more specific than Jstack's catch all route /api/ so it worked for me. but how do we take advantage of the middlewares on the jstack?
I ended up defining betterAuth({}) twice, once on the nextjs app under lib, and once in the hono app in jstack.ts. I did the same for the database/drizzle.
I'm assuming this is correct since the Hono app is intended to be deployed on cloudflare workers, while the nextjs app on vercel, but i'm not sure if having 2 clients is the right approach. Maybe there is a way to define it once in Hono (server) and serve the endpoints through the router for the next app to use.
Let me know if you have any ideas regarding this, I will link a repo that has my current approach. Thanks a lot!
https://github.com/yahyazgour/jstack-betterauth
13 replies