Extend type user
I added an additionalFields but when I import type { User } from "better-auth";
I get only the default form
13 Replies
Thx for any help
Solution
Found a quick fix adding this in the auth.ts
But lets see what mclovin have to say 🙂
Are you using authClient on the frontend? if so make sure you add the inferAdditionalFields plugin
I have only this in my authClient
Here's an example in my code, you can copy the additional fields from your backend code and remove any unneccesary fields like references etc

thx a lot for your help
the boss
If you are satisfied with my answer please take the time and use the context window to mark it as solution 🙂
Yeah Last question
How you import the type in the front ?
export type Session = typeof authClient.$Infer.Session; works
Yeah but Thats the session
I found thats quick fix export type User = typeof auth.$Infer.Session["user"];
Yea I think thats the best way to get the User type. If you use the inferAdditionalFields plugin the type will be inferred automagically though
thx a lot