9 ms·
Auth.js Authentication for the Web
- moneywoes 4y agoIs there a faster MVP stack than this plus next js and maybe something like supabase for the db?
- moneywoes 4y agoWould use the next js for the api as well
- FractalHQ 4y agoSvelteKit gives tangible speed and DX advantages over React that can be measured in less LOC.
- satvikpendem 4y agoThen you'd have to use Svelte which I dislike over React, not the least of which is templating. After having used Vue and Angular before switching to React, you couldn't pay me to go back to logic in an HTML DSL. I can't look at v-for or ngIf again.
- FractalHQ 4y agoAs someone who dislikes Vue and Angular but loves Solid and Svelte, I understand your reservations but I have to ask- have you ever built something non-trivial with Svelte? The list of DX improvements using TS in a framework like Svelte that gets out of your way without a labyrinth of gotchas and framework specific footguns and api patterns born through a decade of tech debt is nothing to scoff at.
- satvikpendem 4y agoThis year I ported a quite complex web app I had in React and TypeScript, into Vue, Angular, Solid, and Svelte, just to see if I were missing anything given the new changes in the frontend ecosystem. I did not find that TypeScript helped more in Svelte than in React, particularly.
- nodoodles 4y agoLetting Supabase handle auth, and not adding this as a dependency? (no dig at authjs, haven't used it, looks great) https://supabase.com/docs/guides/auth/overview https://supabase.com/docs/guides/auth/overview (and +1 to iteration speed and brevity using SvelteKit)
- simantel 4y agoThis might be fast for JS, but Rails is the GOAT for MVPs.
- loh 4y agoGive Molecule.dev a look. (I'm the creator. Lots of open source improvements in the future, but for now, it is what it is.)
- jokethrowaway 4y agoI've been using https://github.com/OrJDev/create-jd-app https://github.com/OrJDev/create-jd-app which is based on solid and it's pretty great. Super fast out of the box, but I also upgraded vite to 4 with a few overrides to get swc. Solid Auth is still a bit immature (I ended up writing my own Auth stack around prisma, trpc and jwt), haven't tried Next Auth
- cglan 4y agoI’ve been using this library extensively, and I highly recommend it. The switch from next-auth to authjs-core is a great move to make it framework agnostic. That said a lot of the documentation is outdated and clearly react focused. I’ve encountered a lot of behavior that’s unexplained unless you dive deep into the code or GitHub issues. For anyone using this with SvelteKit, or just in general definitely contribute to the documentation if you can! It would help a lot!
- l5870uoo9y 4y agoIt is definitely fairly easy to get started with and supports a wide range of authenticators (at least next-auth does, authjs not so many at the moment). The work on next-auth has been stopped in favour of this (also after some issues and rollback [1]). One thing I was pleasantly surprised by was how easy it is too rollout email authentication via magic links and how relatively good it looks/behaves out of the box [2]. All you need is to add SMTP url and add the config. It is also worth noting that it doesn't work for nextjs yet. [1]: https://github.com/nextauthjs/next-auth/pull/6132 https://github.com/nextauthjs/next-auth/pull/6132 [2]: https://aihelperbot.com/signin https://aihelperbot.com/signin Edit: Formatting.
- doodlesdev 4y agoI'm waiting for a documentation PR to be merged at this moment. My personal experience with the library has been the same. However the lacking documentation SERIOUSLY hurts it, it's very easy to use if you already know what to do because you read the code, but if you went through that effort you could use just about anything else. Hopefully the team behind steps up their documentation game, authjs is something I have been waiting for a long long time and I overall like the decisions made by the team till now.
- cmdli 4y agoAre there any plans to support passkeys/WebAuthN? I feel like that should be a fairly straightforward thing to support since all browsers support it.
- 411111111111111 4y agoThis looks like a library for social auth /various authentication providers. WebAuthN/passkeys would have to be implemented on the provider side, not the client, so highly unlikely that this is planned unless their authentication server documentation was too well hidden for me.
- random_kris 4y agoYou could do it with a custom provider. You basically can define your own flow and inside that use the passkeys. I plan on doing it this way in the product that i am working on, but to save time I use a parallel auth system that just plug and plays with react and then I do some user mapping in my backend (ugly haha but for now is good)
- worldmerge 4y agoDoes this support Yubikeys and webauth?
- dt3ft 4y agoIs it just me or could the sales pitch use some work? What is this? Why use it? Elevator pitch, that is. Calling it “authentication for the web” is way too generic.
- alfanick 4y agoIt's some JS lib abstracting over some authentication providers. But this doesn't sound sexy anymore.
- spiffytech 4y agoIt sounds like it's similar to Passport.js, which let's you add support for 3rd-party auth systems by just supplying API credentials instead of implementing an OAuth etc flow yourself. It still leaves a lot of authn/authz work up to you, but it simplifies putting a "log in with Google" button on your site.
- sanjayio 4y agoIt's actually generic "authentication for the web" which is why it comes off as generic. They started off with being authentication for NextJS and it was definitely helpful for a quick auth implementation. Now it's being opened up to any web framework which is kind of a cool evolution.
- sirius87 4y agoI went down the rabbithole of using next-auth (now authjs) for a recent project. Having used Passport.js [1] for Oauth2 the last time I was doing node.js ~3 years ago, I found this library to have many footguns as comments/answers on SO and Github. Seems like many people are trying to shoehorn their codebase [2] (!!) to make it work with the way the library manages sign-in flow, redirects, cookies, logout, etc. [3] These were solved problems in the MEAN stack era with middlewares, but now that Next.js/react is the trend, people are doing everything they can to make it work - from relaxing security configs, to stashing things in the JWT just so some callback can get an additional piece of data [4]. [1] https://github.com/jaredhanson/passport https://github.com/jaredhanson/passport [2] https://github.com/nextauthjs/next-auth/issues/600#issuecomment-1235488781 https://github.com/nextauthjs/next-auth/issues/600#issuecomm... [3] https://stackoverflow.com/questions/tagged/next-auth?sort=MostVotes https://stackoverflow.com/questions/tagged/next-auth?sort=Mo... [4] https://stackoverflow.com/questions/64576733/where-and-how-to-change-session-user-object-after-signing-in https://stackoverflow.com/questions/64576733/where-and-how-t... EDIT: more links in case it helps the authors improve DX
- thinkingkong 4y agoAgreed. This library is so opinionated that it more or less becomes useless. Youre way better off using iron-session or just go all the way and use a provider like Auth0, etc.
- 0xblinq 4y agoAgree. iron-session is great
- moojd 4y agoThe nextjs team for the longest time seemed openly hostile to server-side features in the GitHub issues. We ended up using the custom server feature to essentially bypass nextjs entirely so we could adequately do things like server-side auth in an explicit way using existing proven middleware. Next auth was inadequate for us mostly because of the limitations of nextjs itself. Nextjs 13.1 just added actual server-side middleware with full control of requests/responses so hopefully things will improve. I haven't fully investigated it yet but I'm hoping we can rip out all of our custom server stuff and replace it with middleware now.
- mrcwinn 4y agoThis is indeed a good library. Well done. An enormous amount of work. For those looking for an out of the box freemium option, Clerk.dev is fantastic. (I'm just a customer. No association or interest otherwise.)
- demarq 4y agohow comes the examples are next-auth and not @next-auth?
- lioeters 4y agoOr, since they have a package called @auth/sveltekit, it might have been better named @auth/next, @auth/next/providers/github, etc.
- leerob 4y agoI believe it's mostly because next-auth was the previous package name, which is still in use, so it needs to get migrated over to @auth/next or similar.
- erikpukinskis 4y agoI’ll hijack to ask a question that’s been on my mind… I’ve heard people say “don’t write your own auth” but I’ve also spent a LOT of time hacking auth libraries to fit custom designs, custom flows, etc. And building tooling to integrate libraries with other infra: middleware, test mocks, etc. My question is this: If you have a full time dev team maintaining an application, is it really that much slower in the long term to maintain your own auth flow? I’ve basically given up on UI frameworks like Material UI because of this issue… if you’re building something customized, and you have full time devs to support it, the “time savings” of using a library like that is, in my opinion, a scam. You feel like you’re getting a lot for free because the stuff that works out of the box is very visible. But the months and months of cumulative time spent dealing with the complexity that comes from customization and extension is invisible, because it’s just bugs you fix, or tasks that take a week instead of a day. My team lost probably a dev month this quarter to react-select because of this. I’ve seen the same happen with Popper, react-table, and dozens of other supposedly helpful libraries. I’m curious what other folks think about auth specifically though. Does auth fit into this pattern, or is it something that you really can meaningfully outsource to a library?
- porsager 4y agoDon't listen to anyone saying "Don't write your own X". These things are not that hard once you filter out all the useless abstractions added by various libraries trying to give you a turn key solution. I suppose many just feel safe leaving responsibility in someone else's hands. I have never looked back after fighting passport.js some 10 years ago - being completely free to make you auth flow exactly how you need it is liberating! Now once you've done that a few times you are also in a much better position to decide if it might actually make sense to use a library or some auth provider for any future solutions.
- jacobsimon 4y agoI agree with your point in general, but I think passport.js and its ecosystem of plugins are very helpful. It’s lightweight and customizable for however you want to fetch and serialize sessions, and there are tons of examples online. Do you need it? No, but it makes it easier to standardize your login methods. A non-engineer on our team was able to build “login with linkedin” in less than a day just by following other examples in our codebase which is pretty powerful.
- thekingshorses 4y agoIs there an auth service/library that works without a server?
- mooreds 4y agoWhat do you mean? I'm not quite sure what you are looking for, but would love to learn more.
- deleted 4y ago[deleted]
- revskill 4y agoI don't have trust in the competence of original author. One example, the Credentials provider is mostly broken, and there's no working example at all ! All i want is simply authenticate with my database, no rocket science.
- leerob 4y agoHere's an example with the credentials provider: https://github.com/vercel/nextjs-mysql-auth-starter/blob/main/pages/api/auth/%5B...nextauth%5D.ts https://github.com/vercel/nextjs-mysql-auth-starter/blob/mai...
- revskill 4y agoIf you're newscomer, come to the docs and the codebase, there's no example at all. The docs is not helpful.
- sanjayio 4y agoI've been using this library as well and I find that this isn't completely true. There are a few examples, but you have to pull and stitch from a few places. The documentation has been improving over the course of the last few months.
- dvh 4y agoYou lost me at mixing underscore and camel case.
- Kiro 4y agoWhere do you see that? Constants are normally written with all caps and underscore while normal variables use camelcase. That's the convention most JS codebases use.
- dvh 4y agoServer code examples
- l5870uoo9y 4y agoI also wondered why the database schema is so bastardized with camel case and snake case column names mixed. Likely legacy, but still messes with the OCD.
- aaws11 4y agois this the parallel to passport js?
- sanjayio 4y agoA little, you could imagine this being a framework and passport being a collection of libraries and less of a rigid framework. I've worked with both and found passport/express to allow a lot more freedom than NextJS/NextAuth. But, NextJS/NextAuth was definitely more seamless to put together a simple POC.
- sanjayio 4y agoHappy to see the team moving in this direction. I've used NextAuth extensively and although it has some sharp edges, I feel like those sharp edges aren't unfixable. The documentation has been improving over the past year. I hope that having to adapt to more web frameworks will actually enhance the flexibility of AuthJS and leave few cases to have to shoehorn a solution.
- muratsu 4y agoI've used this lib in a few MVPs and it was easy to use if you do things their way (which wasn't that big of a deal for an MVP). > The functionality provided for credentials based authentication is intentionally limited to discourage use of passwords due to the inherent security risks associated with them and the additional complexity associated with supporting usernames and passwords. I have to admit while as a dev I sympathize with this stance, as an end-user I really hate it. I pay for a pwd manager and feel much better about using a user+pwd combo. I get that oauth is more secure in general but somehow I feel uneasy to give access (even limited) to my personal gmail or github.
- DrewADesign 4y agoAgreed. I'm a bit more privacy-focused than most but oauth + 3rd party seems like solution that should solve a specific problem or enfranchise a specific group of users and always have a password-based alternative. It's probably futile, but I'm just not particularly enamored with the idea of openly inviting all of those big companies and their greedy telemetry vacuums into every little last corner of my life.
- satvikpendem 4y agoWhat about a passwordless / magic link to your email? I've found that to be the best option as a dev/user, since no passwords necessary, no lock-in ("which OAuth2 provider did I use for this account, Google, Apple, GitHub, or Facebook?"), and it works decently well on all devices.
- muratsu 4y agoI forgot the exact issue but if I recall it correctly, pwdless sessions are meant to be short lived sessions. I equally dislike reauthenticating my sessions every day
- satvikpendem 4y agoWhy would they be short-lived? Just send a refresh and access token like normal authentication, the only thing you're changing is whether the user authenticates from a password versus a link which has a unique identifier, they're both looked up from the database / in-memory cache all the same.
- apatheticonion 4y agoIn my opinion. Writing an oauth oidc client is too easy to warrant using a library like this. Use a service like AWS Cognito or Auth0 to handle auth/federated connections and hand write a simple client to adapt to your auth provider. You can have a client-side only flow or you can use a server, in either case it's pretty trivial to implement.
- hestefisk 4y agoWhy risk the potential security holes that have already been solved for you?
- jijji 4y agohas anyone tried HybridAuth for php? it seems like they support over 40 authentication providers [0] [0] https://hybridauth.github.io/providers.html https://hybridauth.github.io/providers.html