eko
eko
BABetter Auth
Created by eko on 4/21/2025 in #help
Super Admin role creation assistance
Hello Team, I am looking into creating a role based access control system within my app, I would like to have SUPERADMIN, ADMIN, USER level roles and wanted to see how i can add a new role and make use of this system. auth-client.ts
import { adminClient } from "better-auth/client/plugins";
import { createAuthClient } from "better-auth/react";
export const { signIn, admin, useSession } = createAuthClient({
/** The base URL of the server (optional if you're using the same domain) */
baseURL: "http://localhost:3000",
plugins: [adminClient()],
});
import { adminClient } from "better-auth/client/plugins";
import { createAuthClient } from "better-auth/react";
export const { signIn, admin, useSession } = createAuthClient({
/** The base URL of the server (optional if you're using the same domain) */
baseURL: "http://localhost:3000",
plugins: [adminClient()],
});
auth.ts
import { betterAuth } from "better-auth";
import { prismaAdapter } from "better-auth/adapters/prisma";
import prisma from "./prisma";
import { admin } from "better-auth/plugins";

export const auth = betterAuth({
database: prismaAdapter(prisma, {
provider: "postgresql", // or "mysql", "postgresql", ...etc
}),
emailAndPassword: {
enabled: true,
},
plugins: [
admin({
adminRoles: ["SUPER_ADMIN", "ADMIN"],
}),
],
});
import { betterAuth } from "better-auth";
import { prismaAdapter } from "better-auth/adapters/prisma";
import prisma from "./prisma";
import { admin } from "better-auth/plugins";

export const auth = betterAuth({
database: prismaAdapter(prisma, {
provider: "postgresql", // or "mysql", "postgresql", ...etc
}),
emailAndPassword: {
enabled: true,
},
plugins: [
admin({
adminRoles: ["SUPER_ADMIN", "ADMIN"],
}),
],
});
5 replies