Additional fields missing from User type

I have added 2 additional fields to better auth with this code:
export const auth = betterAuth({
appName: 'Test',
user: {
additionalFields: {
timezone: {
type: 'string',
default: 'UTC',
nullable: false,
},
customerId: {
type: 'string',
default: '',
nullable: false,
},
},
},
export const auth = betterAuth({
appName: 'Test',
user: {
additionalFields: {
timezone: {
type: 'string',
default: 'UTC',
nullable: false,
},
customerId: {
type: 'string',
default: '',
nullable: false,
},
},
},
i'm working only server side, is there something like type Session = typeof auth.$Infer.Session for the User type?
5 Replies
Benfa
BenfaOP3w ago
i'm working on server side so i don't use "createAuthClient" but i use auth directly, which i think should be faster beacuse it shouldn't make any http request since i'm on the server already.
bekacru
bekacru3w ago
Session = typeof auth.$Infer.Session //this includes both `session` and `user` keys
Session = typeof auth.$Infer.Session //this includes both `session` and `user` keys
KiNFiSH
KiNFiSH3w ago
there is a server one right below to it
Megamind
Megamind2w ago
how can i add additional feilds to the members schema? i am using organizations plugin. could you please guide me on this? i have defined the schema in Prisma manually, but the values are not being added here is my code.
await auth.api.addMember({
body: { organizationId,
userId: user.id, role:faker.helpers.arrayElement(["admin", "member"] as const),
customFields: {
address: faker.location.streetAddress(),
zipCode: faker.location.zipCode(),
},
},
});
await auth.api.addMember({
body: { organizationId,
userId: user.id, role:faker.helpers.arrayElement(["admin", "member"] as const),
customFields: {
address: faker.location.streetAddress(),
zipCode: faker.location.zipCode(),
},
},
});

Did you find this page helpful?