King Alastor
King Alastor
Explore posts from servers
BABetter Auth
Created by King Alastor on 2/27/2025 in #bug-reports
Better-auth cannot be set up using pg Pool and postgres
@bekacru need anything else?
8 replies
BABetter Auth
Created by King Alastor on 2/27/2025 in #bug-reports
Better-auth cannot be set up using pg Pool and postgres
and here's the auth-client
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>()],
});

export const { signIn, signOut, useSession } = authClient;
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>()],
});

export const { signIn, signOut, useSession } = authClient;
8 replies
BABetter Auth
Created by King Alastor on 2/27/2025 in #bug-reports
Better-auth cannot be set up using pg Pool and postgres
and here's auth.ts
import { betterAuth } from "better-auth";
import { getUserCount } from "../data/auth-data";
import { Pool } from "pg";

export const auth = betterAuth({
database: new Pool({
connectionString: process.env.DATABASE_URL,
}),
socialProviders: {
google: {
clientId: process.env.AUTH_GOOGLE_ID || "",
clientSecret: process.env.AUTH_GOOGLE_SECRET || "",
},
},
session: {
expiresIn: 60 * 60 * 24 * 30,
updateAge: 60 * 60 * 24,
cookieCache: {
enabled: true,
maxAge: 60 * 60 * 24,
},
},
user: {
modelName: "users",
additionalFields: {
userName: {
type: "string",
required: false,
},
// more fields
},
},
databaseHooks: {
user: {
create: {
before: async (user) => {
// stuff here
},
},
},
},
});
import { betterAuth } from "better-auth";
import { getUserCount } from "../data/auth-data";
import { Pool } from "pg";

export const auth = betterAuth({
database: new Pool({
connectionString: process.env.DATABASE_URL,
}),
socialProviders: {
google: {
clientId: process.env.AUTH_GOOGLE_ID || "",
clientSecret: process.env.AUTH_GOOGLE_SECRET || "",
},
},
session: {
expiresIn: 60 * 60 * 24 * 30,
updateAge: 60 * 60 * 24,
cookieCache: {
enabled: true,
maxAge: 60 * 60 * 24,
},
},
user: {
modelName: "users",
additionalFields: {
userName: {
type: "string",
required: false,
},
// more fields
},
},
databaseHooks: {
user: {
create: {
before: async (user) => {
// stuff here
},
},
},
},
});
8 replies
BABetter Auth
Created by King Alastor on 2/27/2025 in #bug-reports
Better-auth cannot be set up using pg Pool and postgres
better-auth.config.ts
export { auth } from './src/lib/auth/auth';
export { auth } from './src/lib/auth/auth';
8 replies
BABetter Auth
Created by King Alastor on 2/27/2025 in #bug-reports
Better-auth cannot be set up using pg Pool and postgres
nothing?
8 replies
BABetter Auth
Created by King Alastor on 2/27/2025 in #help
database: new Pool
it doesn't seem like it respects the remapping to: tables: { user: "users", account: "account", session: "session", verification: "verification" },
4 replies
BABetter Auth
Created by King Alastor on 2/27/2025 in #help
database: new Pool
the migration file tries to create "user" table but you can't create "user" table in postgresql so it fails
4 replies
BABetter Auth
Created by Exoden on 2/26/2025 in #help
Update session manually
in combination with the "additionalFields"
16 replies
BABetter Auth
Created by Exoden on 2/26/2025 in #help
Update session manually
16 replies
BABetter Auth
Created by Exoden on 2/26/2025 in #help
Update session manually
this is the only way i've found so far to update the user with additional info
16 replies
BABetter Auth
Created by Exoden on 2/26/2025 in #help
Update session manually
16 replies
BABetter Auth
Created by King Alastor on 2/3/2025 in #help
Argument `token` is missing.
okay, i created a separate clean project and ran the cli tool there to get the schema it needs (this was attempt #2 this way) and now i got the schema it needed and it works. Wish the website had the schema it needs just there to copy/paste so i could know exactly what it needs rather than hoping the cli tool worked. I used the cli tool in my main project as well so i got some messed up schemas
7 replies
BABetter Auth
Created by King Alastor on 2/3/2025 in #help
Argument `token` is missing.
i would have assumed the npx @better-auth/cli generate would already create the exact schema it needs to work
7 replies
BABetter Auth
Created by King Alastor on 2/3/2025 in #help
Argument `token` is missing.
remove the token field or make it optional?
7 replies