Live data from Hacker News

Launch HN: Better Auth (YC X25) – Authentication Framework for TypeScript

news.ycombinator.com

71–80 of 112 posts

Re: Launch HN: Better Auth (YC X25) – Authentication Framework for TypeScript

#71
post #59

Have been a proud better auth user for the last 6 months! Loved it so far, especially the fact that it's FOSS. Now that it's a venture-funded YC company, I am worried about using it. Should I be?

As I mentioned in the post, our goal is to help developers own their Auth. And now that we’re funded, it’d help us pursue this goal even more aggressively and give people more confidence.

Re: Launch HN: Better Auth (YC X25) – Authentication Framework for TypeScript

#72

Does it handle: - Federated sign-in/out? In next-auth, it is a giant pain to implement: https://github.com/nextauthjs/next-auth/discussions/3938 - Automated refreshing of JWT tokens on the client-side? I always end up having to implement my own logic around this. The big problem is if you have multiple API calls going out and they all require JWT auth, you need to check the JWT validity and block the calls until it i…

How did you resolve the multiple refresh calls issue? Do you use swr hooks on the front end? Been thinking about how to do this myself.

Re: Launch HN: Better Auth (YC X25) – Authentication Framework for TypeScript

#73
My experience with auth solutions/libraries is you invariably want to customize some flow/data/functions, but it's impossible because the library isn't flexible enough.

A better solution might be premade auth primitives (oauth providers, db adapters) that you copy paste into your codebase shadcn-style, and modify when necessary.

I feel like "don't roll your own auth" is less true than it was 5-10 years ago as now there is an abundance of good references and core libraries.

Re: Launch HN: Better Auth (YC X25) – Authentication Framework for TypeScript

#75

Does it handle: - Federated sign-in/out? In next-auth, it is a giant pain to implement: https://github.com/nextauthjs/next-auth/discussions/3938 - Automated refreshing of JWT tokens on the client-side? I always end up having to implement my own logic around this. The big problem is if you have multiple API calls going out and they all require JWT auth, you need to check the JWT validity and block the calls until it i…

How did you resolve the multiple refresh calls issue? Do you use swr hooks on the front end? Been thinking about how to do this myself.

No hooks on the FE side. We use a global lock via a promise. Our API clients are not tied to react in any way.

For all API calls, if the lock is not set, it checks if the JWT is still valid. If it is not, then the lock is set by assigning a new promise to it and saving the resolve call as an external variable to be called after the refresh is done (which resolves the held promise on the other calls, allowing the latest token to be used).

All calls await the lock; it either waits for the refresh to complete or just moves on and performs validation with the currently set token.

Looks like this:

- await on lock; if the lock has been resolved, will just continue on

- Check for JWT validity via exp check (the API server itself would be responsible for checking signature and other validity factors); if not valid, update lock with a new promise and hold the resolver. Perform refresh. Release lock by resolving the promise.

- Use current / refreshed JWT for API call

Re: Launch HN: Better Auth (YC X25) – Authentication Framework for TypeScript

#76
post #40

Does it handle: - Federated sign-in/out? In next-auth, it is a giant pain to implement: https://github.com/nextauthjs/next-auth/discussions/3938 - Automated refreshing of JWT tokens on the client-side? I always end up having to implement my own logic around this. The big problem is if you have multiple API calls going out and they all require JWT auth, you need to check the JWT validity and block the calls until it i…

- Not right now, but there’s already an open issue and a PR in progress. - We don’t use JWTs directly, and sessions always require state (it’s not stateless). And yeah, both the client and server handles automatic session refresh. - Yes, we support both multiple sessions or having different organizations open in different tab: https://www.better-auth.com/docs/plugins/multi-session - Yes, that’s possible, you just nee…

As another asked, "why?" on no JWT? It makes interfacing with our API servers so much easier as we don't need to maintain infra for sessions and wouldn't be limited by the 4kb limit for sending cookies.

Re: Launch HN: Better Auth (YC X25) – Authentication Framework for TypeScript

#79
post #31

Tangentially related, but have you thought about a go to market strategy related to AI? I started a new side project with Cursor to see how it goes, and it suggests a lot of packages for a lot of things (often not even suggests, assume you want it and ask you to install already). I imagine there will be a “AIO” AI optimization field soon. Have you considered at all? I mean. If I explicitly ask Cursor models to use Be…

Ideally assistants will look at your package.json then make web calls to bring in the docs. Maybe a README.AI file that is more token efficient can provide the data.

Re: Launch HN: Better Auth (YC X25) – Authentication Framework for TypeScript

#80

Super happy users :) Agree w/ what everyone has said. For us an extra benefit is the ability to host our user data in our own DB so that we can then dig into it w/ Index. Clerk keeps the data locked in and their "analytics" page is very very limited.

I happened to pick up Clerk for its ease of use and accessible free tier for my SaaS. The data locking was “solvable” but way too much effort as a solo dev. I had to use their webhook tool and set up a separate Inngest service to sync the data.

I’m very curious about Better Auth from what I’ve heard so far. I wish I knew about it sooner!

Post reply on HN