yoyojoe
yoyojoe
BABetter Auth
Created by yoyojoe on 3/19/2025 in #help
Stripe one time payments?
Also, I've seen a few people requesting a usage plugin which I think I'll end up building soon. A usage plugin tied to an API key would be so cool.
10 replies
BABetter Auth
Created by yoyojoe on 3/19/2025 in #help
Stripe one time payments?
@bekacru I haven't given it much thought from a design perspective but something similar to how subscriptions are handled (my guess is it'll be a lot simpler). My use case might be somewhat niche. I'm trying to build an application where usage is tied to a token system. The user will buy more tokens in order to gain more usage. For more context, its an AI agent SaaS powered by Mastra.ai. Once I get more into the build I can give better examples of how it could be implemented into the stripe plugin.
10 replies
BABetter Auth
Created by yoyojoe on 3/19/2025 in #help
Stripe one time payments?
Hey thank you @bekacru so glad you guys thought about extending the webbooks. I don't mind this implementation at all, but are there any plans to add one time payments into the stripe plugin in the future?
10 replies
BABetter Auth
Created by yoyojoe on 3/13/2025 in #help
Admin Users Count
classic hahaha. Thank you again for working through this with me
29 replies
BABetter Auth
Created by yoyojoe on 3/13/2025 in #help
Admin Users Count
hell yeah
29 replies
BABetter Auth
Created by yoyojoe on 3/13/2025 in #help
Admin Users Count
Also note that removing the limit on the query does not change the response but removes the limit amount returned.
{
"users": [
{
"id": "****",
"name": "****",
"email": "****",
"emailVerified": true,
"image": "****",
"createdAt": "2025-03-16T22:53:58.000Z",
"updatedAt": "2025-03-16T22:53:58.000Z",
"role": "admin",
"banned": null,
"banReason": null,
"banExpires": null
}
]
}
{
"users": [
{
"id": "****",
"name": "****",
"email": "****",
"emailVerified": true,
"image": "****",
"createdAt": "2025-03-16T22:53:58.000Z",
"updatedAt": "2025-03-16T22:53:58.000Z",
"role": "admin",
"banned": null,
"banReason": null,
"banExpires": null
}
]
}
29 replies
BABetter Auth
Created by yoyojoe on 3/13/2025 in #help
Admin Users Count
ahh this might be the case
29 replies
BABetter Auth
Created by yoyojoe on 3/13/2025 in #help
Admin Users Count
So with the following query:
// Admin count query
const { data: adminCountData } = useQuery<UsersResponse>({
queryKey: ["users-admin-count"],
queryFn: async () => {
try {
const data = await client.admin.listUsers(
{
query: {
limit: 1,
filterField: "role",
filterOperator: "eq",
filterValue: "admin",
}
},
{
throw: true,
},
);
return data as UsersResponse;
} catch (error: any) {
console.error("Failed to fetch admin count:", error);
return { users: [], total: 0, limit: 0 } as UsersResponse;
}
},
staleTime: 5 * 60 * 1000, // 5 minutes
});
// Admin count query
const { data: adminCountData } = useQuery<UsersResponse>({
queryKey: ["users-admin-count"],
queryFn: async () => {
try {
const data = await client.admin.listUsers(
{
query: {
limit: 1,
filterField: "role",
filterOperator: "eq",
filterValue: "admin",
}
},
{
throw: true,
},
);
return data as UsersResponse;
} catch (error: any) {
console.error("Failed to fetch admin count:", error);
return { users: [], total: 0, limit: 0 } as UsersResponse;
}
},
staleTime: 5 * 60 * 1000, // 5 minutes
});
the response cached is the following:
{
"users": [
{
"id": "****",
"name": "****",
"email": "****",
"emailVerified": true,
"image": "****",
"createdAt": "2025-03-16T22:53:58.000Z",
"updatedAt": "2025-03-16T22:53:58.000Z",
"role": "admin",
"banned": null,
"banReason": null,
"banExpires": null
}
],
"limit": 1
}
{
"users": [
{
"id": "****",
"name": "****",
"email": "****",
"emailVerified": true,
"image": "****",
"createdAt": "2025-03-16T22:53:58.000Z",
"updatedAt": "2025-03-16T22:53:58.000Z",
"role": "admin",
"banned": null,
"banReason": null,
"banExpires": null
}
],
"limit": 1
}
Note: I'm blocking sensitive info in the returned request, that's not the actual response.
29 replies
BABetter Auth
Created by yoyojoe on 3/13/2025 in #help
Admin Users Count
@Netrifier Now when I query using the admin client I'm not getting a total back at all.
29 replies
BABetter Auth
Created by yoyojoe on 3/13/2025 in #help
Admin Users Count
Here's my auth-client.ts:
import { createAuthClient } from "better-auth/react"
import { adminClient } from "better-auth/client/plugins"

export const authClient = createAuthClient({
baseURL: "http://localhost:3000", // the base url of your auth server
plugins: [adminClient()]
})
import { createAuthClient } from "better-auth/react"
import { adminClient } from "better-auth/client/plugins"

export const authClient = createAuthClient({
baseURL: "http://localhost:3000", // the base url of your auth server
plugins: [adminClient()]
})
and here is my auth.ts file:
import { betterAuth } from "better-auth";
import { admin, openAPI } from "better-auth/plugins";
import db from "@/db";
import { nextCookies } from "better-auth/next-js";
import { drizzleAdapter } from "better-auth/adapters/drizzle";

export const auth = betterAuth({
database: drizzleAdapter(db, {
provider: "sqlite",
}),
emailAndPassword: {
enabled: true
},
socialProviders: {
google: {
clientId: process.env.GOOGLE_CLIENT_ID as string,
clientSecret: process.env.GOOGLE_CLIENT_SECRET as string,
},
},
plugins: [
openAPI(),
admin(),
nextCookies()
]
})
import { betterAuth } from "better-auth";
import { admin, openAPI } from "better-auth/plugins";
import db from "@/db";
import { nextCookies } from "better-auth/next-js";
import { drizzleAdapter } from "better-auth/adapters/drizzle";

export const auth = betterAuth({
database: drizzleAdapter(db, {
provider: "sqlite",
}),
emailAndPassword: {
enabled: true
},
socialProviders: {
google: {
clientId: process.env.GOOGLE_CLIENT_ID as string,
clientSecret: process.env.GOOGLE_CLIENT_SECRET as string,
},
},
plugins: [
openAPI(),
admin(),
nextCookies()
]
})
29 replies
BABetter Auth
Created by yoyojoe on 3/13/2025 in #help
Admin Users Count
Hey @Netrifier. See below for my config:
import { createAuthClient } from "better-auth/react"
import { adminClient } from "better-auth/client/plugins"

export const authClient = createAuthClient({
baseURL: "http://localhost:3000", // the base url of your auth server
plugins: [adminClient()]
})
import { createAuthClient } from "better-auth/react"
import { adminClient } from "better-auth/client/plugins"

export const authClient = createAuthClient({
baseURL: "http://localhost:3000", // the base url of your auth server
plugins: [adminClient()]
})
29 replies
BABetter Auth
Created by yoyojoe on 3/13/2025 in #help
Admin Users Count
Sorry. Just realized I didn’t respond. I did try this but got a type error. I looked into it further and filter isn’t a query option. I’m going to update and see if that changes anything
29 replies
BABetter Auth
Created by yoyojoe on 3/13/2025 in #help
Admin Users Count
Whats up @Lick A Brick. I'm expecting the total to be equal to the number of users with the given filter criteria. I only have 1 admin user so I would expect "total":6 Right now its returning the total number of all users
29 replies
BABetter Auth
Created by yoyojoe on 3/13/2025 in #help
Admin Users Count
No description
29 replies
BABetter Auth
Created by yoyojoe on 2/9/2025 in #help
Correct way to create webhooks
Awesome thank you @bekacru I’ll run it.
4 replies