Missing field in session object with drizzle adapter
I'm using BetterAuth with the drizzle adapter in my next.js application and have added a custom
isAdmin
field to my user schema. Despite the field existing in my database and configuring additionalFields in BetterAuth, session.user does not include isAdmin
when I log it. I've also attempted to use the inferAdditionalFields plugin on the client side, but it still doesn't appear in the session object. I'm looking for a solution to correctly include isAdmin
in the session data.
here's my code for auth:
and here's my code for authClient:


Solution:Jump to solution
Don't put the additional fields in the schema.
It should be at the
betterAuth
level.
Here is how it should be:
```ts...6 Replies
I tried the solution you provided, but instead, I encountered an internal server error

my auth client code:
my server auth config:
The error code state {"message":"Failed to get session","code":"FAILED_TO_GET_SESSION"} from /get-session
Solution
Don't put the additional fields in the schema.
It should be at the
betterAuth
level.
Here is how it should be:
Oh yes you are right!
It's my bad ;((
I really appreciate it , thanks a lot!
No worries :)