rhitune
rhitune
BABetter Auth
Created by rhitune on 4/14/2025 in #help
session object on databasehook
session: {
additionalFields: {
isCompletedOnboarding: {
type: "boolean",
defaultValue: false,
},
},
},
session: {
additionalFields: {
isCompletedOnboarding: {
type: "boolean",
defaultValue: false,
},
},
},
I cant use it.
databaseHooks: {
session: {
create: {
before: async (session) => {
if (session.isCompletedOnboarding) {
const organization = await getActiveOrganization(session.userId);
return {
data: {
...session,
activeOrganizationId: organization?.id,
},
};
}

return {
data: {
...session,
},
};
},
},
},
},
databaseHooks: {
session: {
create: {
before: async (session) => {
if (session.isCompletedOnboarding) {
const organization = await getActiveOrganization(session.userId);
return {
data: {
...session,
activeOrganizationId: organization?.id,
},
};
}

return {
data: {
...session,
},
};
},
},
},
},
6 replies
BABetter Auth
Created by rhitune on 4/14/2025 in #help
couldnt find organization.listInvitations
https://www.better-auth.com/docs/plugins/organization#list-invitations I couldnt find a function const invitationsR = await authClient.organization.listInvitations({ query: { organizationId: "organization-id", // optional, by default it will use the active organization }, });
10 replies
BABetter Auth
Created by rhitune on 4/10/2025 in #help
Polar error after upgrading to zod 4 beta
There is an error when i updated my zod version to latest zod@4-beta
TypeError: __TURBOPACK__imported__module__$5b$project$5d2f$node_modules$2f40$polar$2d$sh$2f$sdk$2f$dist$2f$esm$2f$models$2f$components$2f$customfieldcheckbox$2e$js__$5b$app$2d$route$5d$__$28$ecmascript$29$__.CustomFieldCheckbox$inboundSchema.and is not a function
at [project]/node_modules/@polar-sh/sdk/dist/esm/models/components/customfield.js [app-route] (ecmascript) (../../../../src/models/components/customfield.ts:53:36)

3 | import { db } from "@/db";
4 | import { organization } from "better-auth/plugins/organization";
> 5 | import { polar } from "@polar-sh/better-auth";
6 | import { Polar } from "@polar-sh/sdk";
7 |
8 | const client = new Polar({ {
page: '/api/auth/sign-in/social'
}
POST /api/auth/sign-in/social 500 in 86ms
TypeError: __TURBOPACK__imported__module__$5b$project$5d2f$node_modules$2f40$polar$2d$sh$2f$sdk$2f$dist$2f$esm$2f$models$2f$components$2f$customfieldcheckbox$2e$js__$5b$app$2d$route$5d$__$28$ecmascript$29$__.CustomFieldCheckbox$inboundSchema.and is not a function
at [project]/node_modules/@polar-sh/sdk/dist/esm/models/components/customfield.js [app-route] (ecmascript) (../../../../src/models/components/customfield.ts:53:36)

3 | import { db } from "@/db";
4 | import { organization } from "better-auth/plugins/organization";
> 5 | import { polar } from "@polar-sh/better-auth";
6 | import { Polar } from "@polar-sh/sdk";
7 |
8 | const client = new Polar({ {
page: '/api/auth/sign-in/social'
}
POST /api/auth/sign-in/social 500 in 86ms
7 replies
BABetter Auth
Created by rhitune on 4/2/2025 in #help
Is there any way to create organization after user create hook?
Im getting UNAUTHORIZED error because im trying to create an organization for user with using user : { create : { after { } }} hook. Is there any way to avoid it?
13 replies
BABetter Auth
Created by rhitune on 3/28/2025 in #help
.cursor/rule For Better-Auth
Hello, is there a cursor rule for better auth docs?
5 replies
BABetter Auth
Created by rhitune on 3/26/2025 in #help
inferAdditionalFields doesnt work?
Im trying to use authClient.signUp.email function on client side. But i cant see my Additional fields on client side. I can see them on server side.
auth-client.ts

import { inferAdditionalFields } from "better-auth/client/plugins";
import { createAuthClient } from "better-auth/react";
import type { auth } from "./auth";

export const authClient = createAuthClient({
plugins: [inferAdditionalFields<typeof auth>()]
});
auth-client.ts

import { inferAdditionalFields } from "better-auth/client/plugins";
import { createAuthClient } from "better-auth/react";
import type { auth } from "./auth";

export const authClient = createAuthClient({
plugins: [inferAdditionalFields<typeof auth>()]
});
auth.ts

import { betterAuth } from "better-auth";
import { drizzleAdapter } from "better-auth/adapters/drizzle";
import { db } from "@/db"; // your drizzle instance

export const auth = betterAuth({
user: {
additionalFields: {
role : {
type : "string",
required: true,
defaultValue: "user",
input : false
},
firstName : {
type : "string",
required: true,
defaultValue: "",
input : true
},
lastName : {
type : "string",
required: true,
defaultValue: "",
input : true
},
phone : {
type : "string",
required: true,
defaultValue: "",
input : true
},
}
},
database: drizzleAdapter(db, {
provider: "pg",
}),
emailAndPassword :{
enabled : true
},
socialProviders: {
google : {
clientId : process.env.GOOGLE_CLIENT_ID!,
clientSecret : process.env.GOOGLE_CLIENT_SECRET!
}
}
});
auth.ts

import { betterAuth } from "better-auth";
import { drizzleAdapter } from "better-auth/adapters/drizzle";
import { db } from "@/db"; // your drizzle instance

export const auth = betterAuth({
user: {
additionalFields: {
role : {
type : "string",
required: true,
defaultValue: "user",
input : false
},
firstName : {
type : "string",
required: true,
defaultValue: "",
input : true
},
lastName : {
type : "string",
required: true,
defaultValue: "",
input : true
},
phone : {
type : "string",
required: true,
defaultValue: "",
input : true
},
}
},
database: drizzleAdapter(db, {
provider: "pg",
}),
emailAndPassword :{
enabled : true
},
socialProviders: {
google : {
clientId : process.env.GOOGLE_CLIENT_ID!,
clientSecret : process.env.GOOGLE_CLIENT_SECRET!
}
}
});
sign up page

const { data , error }= await authClient.signUp.email({
firstName : signUpData.firstName,
lastName : signUpData.lastName,
email : signUpData.email,
password : signUpData.password,
phone : signUpData.phone
})
sign up page

const { data , error }= await authClient.signUp.email({
firstName : signUpData.firstName,
lastName : signUpData.lastName,
email : signUpData.email,
password : signUpData.password,
phone : signUpData.phone
})
6 replies