feat: Better Auth
Is your feature request related to a problem? Please describe.
Although still in beta (like next-auth), another good auth package would be better-auth
Describe the solution you'd like to see
Better Auth
Describe alternate solutions
Better Auth
Additional information
No response
Any updates on this? Better Auth hit v1 a few months ago (on Nov 2023) and is such a good auth solution. Clears NextAuth/Auth.js imo and does everything better. Here are some things I can think of off the top of my head:
- Significantly better docs than NextAuth/Auth.js (Better Auth docs cover almost every edge case, unlike Auth.js v5 beta where I had to look up 3rd party guides to setup slightly more 'complex' features)
- Does all the basics
- Email/password (this is not a 2nd class option on Better Auth)
- Credentials-based auth with either email, username, or phone numbers
- Magic Links
- OTP (for both email and phone numbers)
- OAuth
- 2FA
- Passkeys
- Lotta "advanced" stuff (built-in rate limiter, better RBAC, organizations, anonymous users, SSO and more)
- Supports Expo too (for
create-t3-turbousers) - Migration guide for existing NextAuth/Auth.js users here (can be included in the T3 docs for existing Auth.js users)
I'm only glazing on Better Auth this much because it'd be a good fit for create-t3-app cus it's also:
- OSS and self-hosted auth (just like Auth.js, unlike Clerk)
- Not a managed auth provider, that happens to let you self-host it (like Supabase Auth, SuperTokens, or Stack Auth)
- Not a low-level "roll-your-own-auth-on-your-own" solution like Lucia or iron-session (mentioned it since the maintainers didn't want to add Lucia to
create-t3-app)
Would love to see this added in! If this is something the maintainers would be open to, I'd love to work on the PR to get this added in!
I would like to see this also
I would also be down to work on this
Hey Hey here an fork from the guy that work on better-auth lib: https://github.com/Bekacru/create-t3-turbo/tree/main
Hey Hey here an fork from the guy that work on better-auth lib: https://github.com/Bekacru/create-t3-turbo/tree/main
Do you know how to run CLI generate app from the fork?
Want to second this. Would love to try T3 stack but been using better-auth lately and refuse to go back to authjs
As another option to consider, there is also Stack Auth which looks promising.
If someone is good with BetterAuth, why not contribute ? π
@MuellerMarvin kind notice: better-auth is far less mature than nextauth. don't waste the time : )
@MuellerMarvin kind notice: better-auth is far less mature than nextauth. don't waste the time : )
I already transferred the entire T3 template to BetterAuth.
It's a blessing, NextAuth is kind of dead to me. π
Open to PRs adding this. Ping me on Discord when you have something up, sometimes my Github notifications gets overwhelmed and I don't check this project on a daily basis
@MuellerMarvin kind notice: better-auth is far less mature than nextauth. don't waste the time : )
I already transferred the entire T3 template to BetterAuth.
It's a blessing, NextAuth is kind of dead to me. π
saying this just to save your time in production. you're welcome.
@MuellerMarvin kind notice: better-auth is far less mature than nextauth. don't waste the time : )
I already transferred the entire T3 template to BetterAuth. It's a blessing, NextAuth is kind of dead to me. π
saying this just to save your time in production. you're welcome.
It's the first time I've heard a negative thing about BetterAuth, but if there really is a major problem with the library, it would probably help mentioning what that problem is.
Maybe consider even opening an issue there, from the feature-set, quality of the docs and structure of the API, it seems to be the best Auth library out there right now, if you're okay with building your own UI around it.
The problem with AuthJS, the missing, missing password auth, difficult to replace sign in pages, among a few. The advantage of it of course having all the pages already in place and being a 3 minute set up, none of your own work needed.
Open to PRs adding this. Ping me on Discord when you have something up, sometimes my GitHub notifications gets overwhelmed and I don't check this project on a daily basis
Might shoot you a PR π€ Thanks for answering on this !
Now that PR is welcome, @CarlosZiegler can you please kindly create a PR to the repo https://github.com/t3-oss/create-t3-turbo ?
hey ho, @MuellerMarvin really nice that you implemented that, I will do that @contrun lets wait the PR here to do same into turbo :).
Hey Hey here an fork from the guy that work on better-auth lib: https://github.com/Bekacru/create-t3-turbo/tree/main
This repo is a great template for using better-auth and expo with trpc. I should add that the trpc integration isn't complete and it took me a while to realise why my protectedProcedures were not getting the auth session.
In particular this line was missing
const cookies = authClient.getCookie(); if (cookies) { headers.set("Cookie", cookies); }
Hope this helps anyone who is facing the same problem I had
There is another one with Prisma https://github.com/iAskShahram/better-t3-app
And if you use Drizzle
git clone -b drizzle --single-branch https://github.com/iAskShahram/better-t3-app.git
Is anyone working on this? If not I am happy to
go ahead @AlpMimaroglu :)
Any updates on this? I'd love to try out the t3 stack for my project, but I'm waiting for better-auth integration. (I know the turborepo version already has it but that one's stuck on tailwind v3..)
I'd love to see this added to the main repo.
+1
I started working on this and got the cli to scaffold the drizzle / prisma schema and auth folder only for app router with trpc (took me a while with help of ai assist). Need to add social and test each combo to make sure they work. I will have some pr up by Monday i believe.
I started working on this and got the cli to scaffold the drizzle / prisma schema and auth folder only for app router with trpc (took me a while with help of ai assist). Need to add social and test each combo to make sure they work. I will have some pr up by Monday i believe.
Edit : I got drizzle + postgres and sqlite working, i am using GitHub o auth instead of discord because i don't use it, I'll test more, tbh I'm shooting in blind and just replicating and creating better-auth variant of variable files and functions (I'm new to this). Edit 2: @CarlosZiegler once I put pr up could you look at it, I am following the variable and file patterns same as current code base. I didn't find any prs with better auth, so I'm doing it blind.
Update: got almost everything working only problem is the e2e test make 512 tests because of better auth option, idk how to approach it. @juliusmarminge I'm new to this GitHub workflow stuff so any point would be appreciated Edit: everything is working, just need review
+1
Update, I got all the combinations to work, just need review, you can test it out on your local end for testing. All feedback welcomed. https://github.com/t3-oss/create-t3-app/pull/2142
+1 be good to see this implemented! π
I can offer you guys this template to get a quick tRPC project started with better-auth.
It also comes with Drizzle and shadcn/ui preinstalled.
I added a brief overview over the differences to the t3-template in the readme.
the issue can be closed as https://github.com/t3-oss/create-t3-app/pull/2142 is merged. In new version you will need to add next cookies plugin for server action in auth client, i have a pr open to update it.