Ping
Ping
BABetter Auth
Created by javid on 3/3/2025 in #help
Using postgres Instead of pg in Better Auth – Is It Possible?
Could you use Kysley postgres-js dialect instead? It uses postgres.js under the hood.
betterAuth({
database: new PostgresJSDialect({
postgres: postgres({
database: 'test',
host: 'localhost',
max: 10,
port: 5434,
user: 'admin',
}),
}),
});
betterAuth({
database: new PostgresJSDialect({
postgres: postgres({
database: 'test',
host: 'localhost',
max: 10,
port: 5434,
user: 'admin',
}),
}),
});
5 replies
BABetter Auth
Created by mohil on 3/3/2025 in #bug-reports
Admin Plugin Issue with better-auth 1.2.1
It was no worries.
4 replies
BABetter Auth
Created by mohil on 3/3/2025 in #bug-reports
Admin Plugin Issue with better-auth 1.2.1
Works for me. Could it be tsserver not updating after you upgraded your better-auth deps?
4 replies
BABetter Auth
Created by joseph013318 on 3/1/2025 in #help
While deploying - A Node.js API is used (process.exit at line: 1451) which is not supported in..
I missunderstood you, sorry.
11 replies
BABetter Auth
Created by joseph013318 on 3/1/2025 in #help
While deploying - A Node.js API is used (process.exit at line: 1451) which is not supported in..
most likely either a export const runtime = 'edge';
Better Auth doesn't work on edge.
11 replies
BABetter Auth
Created by Sthap on 2/25/2025 in #help
Missing field in session object with drizzle adapter
No worries :)
12 replies
BABetter Auth
Created by Sthap on 2/25/2025 in #help
Missing field in session object with drizzle adapter
Don't put the additional fields in the schema. It should be at the betterAuth level. Here is how it should be:
export const auth = betterAuth({
secret: process.env.SECRET!,
database: drizzleAdapter(db, {
provider: "pg",
schema: {
user,
verification,
session,
account,
},
}),
user:{
additionalFields: {
isAdmin: {
type: "boolean",
required: true,
defaultValue: false,
input: false
},
},
},
emailAndPassword: {
enabled: true,
requireEmailVerification: false,
},
socialProviders: {
google: {
clientId: process.env.GOOGLE_CLIENT_ID! as string,
clientSecret: process.env.GOOGLE_CLIENT_SECRET! as string,
},
},
plugins: [username()],
})
export const auth = betterAuth({
secret: process.env.SECRET!,
database: drizzleAdapter(db, {
provider: "pg",
schema: {
user,
verification,
session,
account,
},
}),
user:{
additionalFields: {
isAdmin: {
type: "boolean",
required: true,
defaultValue: false,
input: false
},
},
},
emailAndPassword: {
enabled: true,
requireEmailVerification: false,
},
socialProviders: {
google: {
clientId: process.env.GOOGLE_CLIENT_ID! as string,
clientSecret: process.env.GOOGLE_CLIENT_SECRET! as string,
},
},
plugins: [username()],
})
12 replies
BABetter Auth
Created by Pororo on 2/25/2025 in #help
Can I integrate Better-Auth between Nextjs and GO Backend?
Otherwise if we're talking about better-auth server instance on Go, that isn't an option as of now.
6 replies
BABetter Auth
Created by Pororo on 2/25/2025 in #help
Can I integrate Better-Auth between Nextjs and GO Backend?
^ this is assuming you're talking about the better-auth server instance being used on Nextjs.
6 replies
BABetter Auth
Created by Pororo on 2/25/2025 in #help
Can I integrate Better-Auth between Nextjs and GO Backend?
It's possible. RIght now, there isn't a better-auth library for GO though, so you'll need to build your own solution which can be challenging. But it's definitely possible. Better Auth works around endpoints, so as long as you have the required headers, body info, method, etc and hit the right endpoints, everything should work.
6 replies
BABetter Auth
Created by Sthap on 2/25/2025 in #help
Missing field in session object with drizzle adapter
Most cases, you define the additional fields here, then on the auth client, when using inferAdditionalFields, the generic would be typeof auth. Like this:
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>()],
});
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>()],
});
12 replies
BABetter Auth
Created by Sthap on 2/25/2025 in #help
Missing field in session object with drizzle adapter
Make sure to actually add the additional fields to your server auth config as well. EG:
import { betterAuth } from "better-auth";

export const auth = betterAuth({
user: {
additionalFields: {
role: {
type: "string",
required: false,
defaultValue: "user",
input: false // don't allow user to set role
},
lang: {
type: "string",
required: false,
defaultValue: "en",
}
}
}
})
import { betterAuth } from "better-auth";

export const auth = betterAuth({
user: {
additionalFields: {
role: {
type: "string",
required: false,
defaultValue: "user",
input: false // don't allow user to set role
},
lang: {
type: "string",
required: false,
defaultValue: "en",
}
}
}
})
More info here
12 replies
BABetter Auth
Created by josh-dev627 on 2/25/2025 in #help
Customizing Sign up flow
Use the after hook to on the user, and from there, create the workspace.
5 replies
BABetter Auth
Created by josh-dev627 on 2/25/2025 in #help
Customizing Sign up flow
5 replies
BABetter Auth
Created by joseph013318 on 2/24/2025 in #help
How to integrate better-auth with cloudfare D1 database?
https://better-auth-git-fork-ping-maxwell-docs-databases-better-auth.vercel.app/docs/adapters/other-relational-databases In the Kysley community dialects, there is Cloudflare d1 DB support. Use that and add it to Better auth, and it should work
7 replies
BABetter Auth
Created by b3nab on 2/21/2025 in #help
better-auth.two_factor cookie not removed on signout?
I'm not too sure. But @bekacru might be of help.
12 replies
BABetter Auth
Created by CapnCrunch on 2/23/2025 in #help
Infer Additional fields
It seems the error comes from the jose lib. But I can't find it anywhere from inferAdditionalFields. By the way, is this error occurring IN runtime? Or does it show you that before hand?
17 replies
BABetter Auth
Created by CapnCrunch on 2/23/2025 in #help
Infer Additional fields
Are you certain it's coming from the inferAdditionalFields client plugin?
17 replies
BABetter Auth
Created by CapnCrunch on 2/23/2025 in #help
Infer Additional fields
Interesting, I'm not sure if I can be of much help, but I will go check the codebase on this.
17 replies
BABetter Auth
Created by kaneki on 2/21/2025 in #help
Custom DB Adapter
I also recommend checking out how Better Auth internally creates adapters for ORMs like Drizzle and stuff. Taking a look at their code can give inspiration on how to approach certain things.
8 replies