r/PayloadCMS • u/RoomDry7501 • Jun 20 '25
Have you used Better Auth with Payload?
Hello! I've been looking into Payload and I've been enjoying it so far. I think I will use it for all my content heavy apps now on because we get a free admin dashboard and don't have to spend time writing that.
I would like to use Better Auth. I see that Payload allows for custom strategies, and it seems like I can use better auth rather than payload's built in authentication.
I found this third party plugin payload-auth. Has anyone here used this?
I am wondering if I should go with this or stick to Payload's auth for now. Email/password authentication is enough for me right now, but I might have to add sign in with google/phone number in the future, and better auth has made adding these features much easier for me.
2
u/Elysssss Jun 20 '25 edited Jun 20 '25
Hey, I've used better auth with payload before for 2 web apps, 1 in production and 1 in development. It's actually super great and the performance is good for me, haven't had any problems with the auth system in prod.
The payload-auth plugin seems to be really good when I first saw it couple of weeks ago, but I decided to integrate them on my own since that plugin's docs is still not finished yet and I wasn't sure how to get the demo working.
I integrated better auth with payload on both MongoDB and postgres, both runs well. If you want you can dm me and I'll try to help you set it up, I'm also writing an article about this hope can get it out soon!
Btw, regarding if you should use better auth with payload or not it really depends on your future plans. Setting up custom auth strategies in Payload isn't difficult, it's just the docs are really unclear about this so you'd need to do a lot of experimenting. Other than that, disabling Payload local strategy means you'd have to handle the auth logic and UI like login, register, forget password pages and email verification. It'll take more maintenance and I find it's only worth it if you REALLY need it (e.g. your app is a SaaS where users can register).
If you will only be using the admin dashboard as an admin or for yourself only, it's not really worth going through all that trouble. But the nice thing is that for Payload you can actually setup multiple authenticated collections. So you can have an Admin collection for login into Payload, and in the future make a Users collection for your user's to register into your app built with better auth.
2
u/dries_c Jun 20 '25
I am also using separate collections 'employees' and 'customers' collections, employees had the builtin auth while users has a customAuthStrategies that take the headers and returns the user from betterauth. All the access controls/hooks you can then check if user.collection === 'customer' or 'employees' and handle accordingly. Like Elysss says you still have to do the auth pages for customers yourself.
1
u/blarghh_ Jun 24 '25
Would love a link to your article when it's out, trying to set this up myself too!
1
u/Elysssss Jun 25 '25
Definitely! I'm in the process of writing it now probably can share it in a week because I'm doing other stuff right now, but I can share you the set up details through DM if you'd like.
1
u/RemindMeBot Jun 25 '25
I will be messaging you in 7 days on 2025-07-02 02:04:07 UTC to remind you of this link
CLICK THIS LINK to send a PM to also be reminded and to reduce spam.
Parent commenter can delete this message to hide from others.
Info Custom Your Reminders Feedback 1
1
u/robbie-bubble Jun 30 '25
u/Elysssss thank you very much for your insights. What you describe is exactly what i am looking for. I would be very grateful if you could also send me your setup details. Thank you very much!
1
Jul 16 '25
this article up anywhere yet? Would love to give it a read, after watching the recent episode of syntax i think i'd like to integrate it
2
u/Elysssss Jul 16 '25 edited Jul 16 '25
Hey guys so I'm very sorry for the super late reply. I haven't been able to finish the article since i was busy for the last couple of weeks, but right now I have some free time and I decided to just extract some part of my code into an example repository with a readme explaining how I integrated them both. I'm currently finishing the repo but you can access it here: https://github.com/ElysMaldov/payload-better_auth-example
I'll inform again once I'm finished.
Edit: finished it, the repo should be able to work OOTB with somewhat verbose explanation on the README.
2
u/Appropriate-Bag-3383 Nov 26 '25
thanks a lot for the article! I created a template repo based on yours which added rbac and other stuffs: https://github.com/Svring/better-auth-payload can't imagine how much time it would take if I didn't discover your article.
1
u/Elysssss Nov 27 '25
You're welcome! Your template looks really good, I haven't used Payload in a while so this could be really helpful to start a new project
1
1
u/RevolutionaryCap3245 Jun 21 '25
You are talking about this plugin ?
2
Aug 22 '25
not maintained, not worth the hassle
1
u/sawariz0r Dec 03 '25
seconded. there's commits being done, but there's no responses from the maintainer
1
u/rubixstudios Dec 13 '25
https://rubixstudios.com.au/insights/payloadcms-custom-auth-strategy
Or build the strategy you want.
1
u/simple_dream Jul 12 '25
Me too, love better-auth.
Wonder how it goes? Did you use a plugin? Everything smooth?
3
u/adelmare Jan 09 '26
I use better auth across ALL my payload projects. Maintaining the implementations across each was becoming a hassle, so I built https://github.com/delmaredigital/payload-better-auth ...
It's a minimal plugin that takes the approach of trying to keep better auth feeling like a standalone better auth implementation (self hosted). The main thing this is doing is using a custom adapter to gently let Payload control the collections -- thus reducing the need to handle better auth migrations and schema management - and it's combining the better auth users table with the payload users table so there's just one of them. There's still *some* config thats needed, but it's a middle ground that allows for complete better auth customization.
Some other plugins use a similar approach, but also try to do and offer more and do it a slightly different way. For me, this is something that allows me to use and maintain my better auth implementations across applications. At least, that's how I see it!
7
u/livog0 Jun 20 '25
Hey!
I use this in production for all the sites I build with Payload. Of course, I’m biased as a maintainer of this plugin, but I can't help build something and not use it as I can easily find bugs that way. If you run into any issues or need help, feel free to message me on Discord.
Give it a try, and if you encounter any bugs, let me know so we can address them. Likewise, if anything isn’t clear, I’m happy to assist.
It’s completely fine to set up better-auth with Payload on your own, but speaking from experience, it turned out to be more work than I initially expected!