deved9036
deved9036
Explore posts from servers
BABetter Auth
Created by Kevin on 4/30/2025 in #help
Help Understanding Better-auth
in your case yes will revalidate everytime since in next if you pass down a dynamic prop like header it will always re-execute
15 replies
BABetter Auth
Created by deved9036 on 4/30/2025 in #help
useSession query behaviour?
oh my apologies!
18 replies
BABetter Auth
Created by Kevin on 4/30/2025 in #help
Help Understanding Better-auth
so i'd be using auth.api.getSession() on top level server component and then go from there
15 replies
BABetter Auth
Created by Kevin on 4/30/2025 in #help
Help Understanding Better-auth
if you are on Next.js I mean it kinda pushes you to go server first anyways
15 replies
BABetter Auth
Created by deved9036 on 4/30/2025 in #help
useSession query behaviour?
yeah I've been looking through the source code a lot in the past 2 days or so, lots of goodies built into it
18 replies
BABetter Auth
Created by deved9036 on 4/30/2025 in #help
useSession query behaviour?
this works
18 replies
BABetter Auth
Created by deved9036 on 4/30/2025 in #help
useSession query behaviour?
No description
18 replies
BABetter Auth
Created by deved9036 on 4/30/2025 in #help
useSession query behaviour?
make sure there is no missmatch between your schema name and fieldName
18 replies
BABetter Auth
Created by deved9036 on 4/30/2025 in #help
useSession query behaviour?
for anyone wondering
18 replies
BABetter Auth
Created by deved9036 on 4/30/2025 in #help
useSession query behaviour?
bless
18 replies
BABetter Auth
Created by deved9036 on 4/30/2025 in #help
useSession query behaviour?
actually nevermind! it did end up woking belss
18 replies
BABetter Auth
Created by deved9036 on 4/30/2025 in #help
useSession query behaviour?
but yeah it doesnt seem to return any extra fields
18 replies
BABetter Auth
Created by deved9036 on 4/30/2025 in #help
useSession query behaviour?
just gave the additionalFields a go, thanks for sharing
18 replies
BABetter Auth
Created by deved9036 on 4/30/2025 in #help
useSession query behaviour?
also looked into customSession but you end up doing another query
import { betterAuth } from "better-auth";
import { drizzleAdapter } from "better-auth/adapters/drizzle";
import { db } from "~/db";
import { verifications, accounts, sessions, users } from "~/db/schema";

export const auth = betterAuth({
database: drizzleAdapter(db, {
provider: "pg",
schema: {
verification: verifications,
account: accounts,
session: sessions,
user: users,
},
}),
//Also if I do a db query inside a custom session you end up querying it twice which is no bueno
//somethin like this
plugins: [customSession(async{user,session} => {
const dbUser = await db.query.users.findFirst()
..
...
//return the extra fields from db here
return {session, user: {...user, points: dbUser.points,}} //etc etc
})]

secret: process.env.BETTER_AUTH_SECRET,
socialProviders: {
github: {
clientId: process.env.GITHUB_CLIENT_ID!,
clientSecret: process.env.GITHUB_CLIENT_SECRET!,
},
google: {
clientId: process.env.GOOGLE_CLIENT_ID!,
clientSecret: process.env.GOOGLE_CLIENT_SECRET!,
},
},
});
import { betterAuth } from "better-auth";
import { drizzleAdapter } from "better-auth/adapters/drizzle";
import { db } from "~/db";
import { verifications, accounts, sessions, users } from "~/db/schema";

export const auth = betterAuth({
database: drizzleAdapter(db, {
provider: "pg",
schema: {
verification: verifications,
account: accounts,
session: sessions,
user: users,
},
}),
//Also if I do a db query inside a custom session you end up querying it twice which is no bueno
//somethin like this
plugins: [customSession(async{user,session} => {
const dbUser = await db.query.users.findFirst()
..
...
//return the extra fields from db here
return {session, user: {...user, points: dbUser.points,}} //etc etc
})]

secret: process.env.BETTER_AUTH_SECRET,
socialProviders: {
github: {
clientId: process.env.GITHUB_CLIENT_ID!,
clientSecret: process.env.GITHUB_CLIENT_SECRET!,
},
google: {
clientId: process.env.GOOGLE_CLIENT_ID!,
clientSecret: process.env.GOOGLE_CLIENT_SECRET!,
},
},
});
18 replies
BABetter Auth
Created by deved9036 on 2/27/2025 in #help
Use Cache Directive with getSession
No description
6 replies
BABetter Auth
Created by ChowderCrab on 2/18/2025 in #help
Cookie cache does not refresh with server-side getSession call
Was looking into this quite a bit! Do you have a code snippet with your latest implementation? I tried to implement it in nextjs solely relying on ‘use cache’ but couldn’t really get it working
34 replies
DTDrizzle Team
Created by deved9036 on 9/23/2023 in #help
Easiest way to add an array of objects?
I am trying to create some sort of tag system that just holds string primites in an array, is it worth creating a seperate schema for this do you reckon?
8 replies
DTDrizzle Team
Created by deved9036 on 9/23/2023 in #help
Easiest way to add an array of objects?
For example here, import { InferSelectModel, relations } from "drizzle-orm"; import { pgTable, serial, text, timestamp, numeric, integer, } from "drizzle-orm/pg-core"; export const users = pgTable("users", { id: serial("id").primaryKey(), name: text("name").notNull(), email: text("email").notNull(), image: text("image").notNull(), clerkId: text("clerkId").notNull().unique(), stripeCustomer: text("stripeCustomer").notNull().unique(), createdAt: timestamp("createdAt").defaultNow().notNull(), }); export const products = pgTable("products", { id: serial("id").primaryKey(), description: text("description").notNull(), details: text("details").notNull(), price: numeric("price").notNull(), authorId: integer("author_id"), title: text("title").notNull(), subtitle: text("subtitle").notNull(), tags: ["journal", "cheap"], }); export const productVariant = pgTable("productVariant", { id: serial("id").primaryKey(), image: text("image").notNull(), color: text("color").notNull(), variantName: text("variantName").notNull(), authorId: integer("author_id"), postId: integer("post_id"), }); export const productVariantRelations = relations(productVariant, ({ one }) => ({ product: one(products, { fields: [productVariant.postId], references: [products.id], }), })); export const userRelations = relations(users, ({ many }) => ({ products: many(products), })); export const productRelations = relations(products, ({ one, many }) => ({ author: one(users, { fields: [products.authorId], references: [users.id], }), productVariant: many(productVariant), })); export type Products = InferSelectModel<typeof users>; export type User = InferSelectModel<typeof users>;
8 replies
DTDrizzle Team
Created by deved9036 on 9/23/2023 in #help
Easiest way to add an array of objects?
I just did a quick search and Bard spat that out and assumed it was a feature 😂
8 replies