Typescript - database hook type inference for additional fields
This is my current
auth.ts
:
In the database -> user -> create -> before hook, despite setting the "role" additional field as required, there is no issue if I were to remove the "role" field, i.e.
i.e. the role "type" is not picked up at all.
I'm also facing a separate type issue client-side, which I've posted here:
https://discord.com/channels/1288403910284935179/1323671049413333033/1323857938875420734
Am I doing something wrong or is this an issue with the type system?7 Replies
Unknown User•4mo ago
Message Not Public
Sign In & Join Server To View
no updates on this?
rather than the type . is it working fine like it gets passed ?
i am doing similiar. the feilds are not added
For type to be picked up you need to infer it:
in auth.ts:
export type User = typeof auth.$Infer.Session.user;
in auth-client:
and what do you mean by not added ? To db? you need to generate the schema after you modified the auth.ts config: npx @better-auth/cli generate
or migrate (works with kysely only)
I am using the organizations plugin. And trying to add addition fields to the members. I have updated the tables manually with prisma schema. The additional fields are not being added to the db.
you have to generate and make sure to add ts infereence on example here - https://www.better-auth.com/docs/concepts/typescript#additional-fields
TypeScript | Better Auth
Better Auth TypeScript integration.