Adding simple role to User Schema
hi guys! im having a little issue with adding a role to my User schema. I'm using Prisma and i wanted to add a role property to the User schema. It all works well, until i need to use the authClient.useSession() hook. I get the session off of it, but when trying to access the session.user.role property, it says there is no role property on it.
What i've already tried:
But if theres no better way to do it, i'll try that option.
What i've already tried:
- Adding aditionalFields property to the better auth instance```tsuser: { additionalFields: { role: { type: "string", } }}```
- Adding the inferAdditionalFields plugins, both ways suggested in here: https://www.better-auth.com/docs/concepts/typescript#inferring-additional-fields-on-client
- Regenerated my Prisma client
But if theres no better way to do it, i'll try that option.

Solution
alright, i'll summarize the fix in here for anybody who happens to have the same issue in the future:
To add a custom field to your User schema:
To add a custom field to your User schema:
- In your auth.ts file, add the user.additionalFields property: (dont mind the prismaAdapter or socialProviders, these are specific to my project)
- in your auth-client.ts file, add the inferAdditionalFields plugins:
- From there, any additional property you add to the User schema, you'll need to include it on the user.additionalFields property from step 1 and they should get automatically picked up when you fetch the user.