trouble with organization creation in the afterEmailVerification callback
Hi everyone!
I'm trying create an organization automatically when a user verifies their email using the afterEmailVerification callback.
```
import { headers } from 'next/headers'
afterEmailVerification: async (user, request) => {...
Microsoft Auth way to grant additional scopes?
is there a way to request additional scopes with microsoft auth. aka grant things like certain api information and that from there user. Say get their minecraft name etc as a example. I know i can do this with a different api but it would be nice if the user would only have to login once
Solution:
nvm i am blind there is "scopes"
make session.user.name null
Hi I am porting my app to better auth and I currently use user.firstName + user.lastName instead of user.name
I managed to add the fields succesfully to the better auth setup and they are properly typed, the issue is since I am not using user.name I would like for it to be typed as null or undefined at least. I was wondering if that was possible of if I need to manually cast the types.
heres are the backend and frontend current implementations:...
Using Organizations with Stripe plugin
When using the stripe plugin with the organization plugin, do i manually need to add the stripeCustomerId to an Org?
I can't finish building Google OAuth on my NuxtJS app
I added the
GOOGLE_CLIENT_ID
, and GOOGLE_CLIENT_SECRET
like the docs' requirements. The screenshots including the errors, and the code snippets. Can anyone tell me that something was wrong? How should I implement the auth?
Migrating From NextAuth to Better Auth, better auth required "account" table for credentials login?
In my next auth database it didnt create any account row for user creadentials login, now as I am migrating from it better auth is looking for account table row of that user which does not exists as nextauth never added such entry!
```js
[Nest] 444150 - 07/30/2025, 8:17:49 PM DEBUG [DB]
------------- [DATABASE DEBUG QUERY] ------------
...
better-auth/cli generate not working
PS C:\Users\x\Desktop\x\frontend> npx @better-auth/cli generate
npm ERR! cb.apply is not a function
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\x\AppData\Roaming\npm-cache_logs\2025-07-30T14_19_26_631Z-debug.log...
Solution:
Used Pnpm and it works
Localization handling by i18n integration or throwing custom errors with predefined endpoints?
Hello Guys,
I can't figure out how to customize the error response from the predefined endpoints.
It's easy to do with the api actions(e.g. auth.api) but I'm trying to follow recommendations and stick to the predefined endpoints.
I'm working on a monorepo with multiple front-end apps and one rest api, And I'm trying to keep my error handling centralized in the API.
So I'm aware of the available hooks like onRequest, onResponse and onError but It doesn't satisfies my needs(because they are on the client)....
Username plugin options issue
I was trying to customize username ..but i could not use usernameNormalization option of the plugin ?
Creating a custom adapter with kysely dialect
I've updated the surrealdb kysely driver to work with SurrealDB 2.x. I'm testing the changes in better-auth. I can't seem to get kysely to use my dialect properly.
How protect API Routes in Next.js
I'm exposing some routes in my Next.js system and I'd like to know the best approach to protect these endpoints using BetterAuth. This system is an automation that runs in another environment. How should it send the credentials? Should it use an API key or a Bearer token?
Is there any material that explains this in more detail?
Also, how would my automation know which API key or token to use?...
db error when running tests
when I run
pnpm test
i get these errors, presumably because the database or whatever wasn't initialised. the docs at https://github.com/better-auth/better-auth/blob/main/CONTRIBUTING.md mention an optional db step but doesn't really go any further
```
better-auth:test: ❯ src/adapters/kysely-adapter/test/number-id/adapter.kysely.number-id.test.ts:90:15
better-auth:test: 88| ...Solution:
wait i just noticed there's a docker compose file
CLI social signup flow
Hi all, I am attempting to make a signup flow in my CLI. I am a little lost on where to start and to make things more complicated I have a separate frontend and backend service on different subdomains. Wondering if anyone has done this and can point me in the right direction.
API Error codes
Thanks for a great library! I want to display error messages in another language than English and am therefore interested to switch based on the
error.body.code
. So far I have come across the USER_ALREADY_EXISTS
code, but doing this manually is tedious - is there any list or reference for all possible error messages? All I can find is this, which is very sparse: https://www.better-auth.com/docs/concepts/api#error-handling.Solution:
```ts
type $ERROR_CODES = {
USER_NOT_FOUND: string;
FAILED_TO_CREATE_USER: string;
FAILED_TO_CREATE_SESSION: string;...
Inserting a user directly into DB
Hi, I'm looking to insert users (users + account) directly into the db - I'm hitting an issue where the hashed password isn't working so I expect I'm missing something where I'm not using the hash function from better-auth. Has anyone else done this? Using email+password credentials & postgres
Is there an function to modify a user custom field?
I added my custom field via the config, generated the schema, all good. I can't seem to find a way to update the contents of the user custom field via the better auth library. I'd understand if that's not a feature that's offered, though it would be convenient to use their client side instance and not have to create a server endpoint and check their privileges. Just want to make sure I'm not missing something.