
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
better-auth-admin
Advanced tools
Admin Dashboard for Better Auth - Manage users, organizations, and sessions
Admin Dashboard for Better Auth - Manage users, organizations, and sessions with a beautiful, modern UI.
Add an admin dashboard to your Express app in 3 lines of code:
import express from "express";
import { betterAuthAdmin } from "better-auth-admin";
const app = express();
app.use(
"/admin",
betterAuthAdmin({
authUrl: "http://localhost:3000",
})
);
app.listen(3000);
// Admin dashboard: http://localhost:3000/admin 🎉
That's it! Your admin dashboard is now available at /admin.

npm install better-auth-admin
# or
pnpm add better-auth-admin
# or
yarn add better-auth-admin
Before using the dashboard, you need to configure Better Auth with the admin plugin.
First, make sure you have Better Auth set up in your project. Then configure the admin plugin:
// auth.ts
import { betterAuth } from "better-auth";
import { admin, organization } from "better-auth/plugins";
export const auth = betterAuth({
database: {
// your database config
},
emailAndPassword: {
enabled: true,
},
plugins: [
admin({
defaultRole: "user",
adminRole: "admin",
// Add your admin user ID here (see Step 3)
adminUserIds: ["your-admin-user-id"],
}),
organization(), // Optional: enable organization management
],
});
Create a user account using Better Auth's standard signup API:
// Using the client SDK
import { createAuthClient } from "better-auth/client";
const authClient = createAuthClient({
baseURL: "http://localhost:3000",
});
// Sign up a new account
await authClient.signUp.email({
email: "admin@example.com",
password: "your-secure-password",
name: "Admin User",
});
Or via API request:
curl -X POST http://localhost:3000/api/auth/sign-up/email \
-H "Content-Type: application/json" \
-d '{"email":"admin@example.com","password":"your-secure-password","name":"Admin User"}'
After creating your account, you need to set the user's role to "admin" in your database:
For SQLite/PostgreSQL/MySQL:
-- Find your user ID first
SELECT id, email, role FROM user;
-- Update the role to admin
UPDATE user SET role = 'admin' WHERE email = 'admin@example.com';
Using Drizzle ORM:
import { db } from "./db";
import { user } from "./db/schema";
import { eq } from "drizzle-orm";
await db
.update(user)
.set({ role: "admin" })
.where(eq(user.email, "admin@example.com"));
Using Prisma:
await prisma.user.update({
where: { email: "admin@example.com" },
data: { role: "admin" },
});
Copy the user ID from Step 3 and add it to your Better Auth config:
// auth.ts
export const auth = betterAuth({
// ... other config
plugins: [
admin({
defaultRole: "user",
adminRole: "admin",
adminUserIds: ["QRWWFp9Vs20Na7sgKJbazYvpcaiK3Ane"], // Your admin user ID
}),
// ...
],
});
Note: The
adminUserIdsarray allows multiple admin users. These users will always have admin access regardless of the database role.
Add the admin dashboard to your Express server:
// server.ts
import express from "express";
import { betterAuthAdmin } from "better-auth-admin";
const app = express();
// Your Better Auth API handler
app.all("/api/auth/*", (req, res) => auth.handler(req, res));
// Mount admin dashboard at /admin
app.use(
"/admin",
betterAuthAdmin({
authUrl: "http://localhost:3000", // Your Better Auth server URL
})
);
app.listen(3000, () => {
console.log("Server running at http://localhost:3000");
console.log("Admin dashboard at http://localhost:3000/admin");
});
| Option | Type | Required | Default | Description |
|---|---|---|---|---|
authUrl | string | ✅ | - | The base URL of your Better Auth server |
title | string | ❌ | "Better Auth Admin" | Custom title for the dashboard |
Here's a complete example with Express, Drizzle, and SQLite:
// src/index.ts
import express from "express";
import { betterAuth } from "better-auth";
import { drizzleAdapter } from "better-auth/adapters/drizzle";
import { admin, organization } from "better-auth/plugins";
import { betterAuthAdmin } from "better-auth-admin";
import { db, schema } from "./db";
// Configure Better Auth
const auth = betterAuth({
database: drizzleAdapter(db, {
provider: "sqlite",
schema,
}),
emailAndPassword: {
enabled: true,
},
plugins: [
admin({
defaultRole: "user",
adminRole: "admin",
adminUserIds: ["your-admin-user-id"],
}),
organization(),
],
});
// Create Express app
const app = express();
app.use(express.json());
// Better Auth API handler
app.all("/api/auth/*", (req, res) => auth.handler(req, res));
// Mount admin dashboard
app.use(
"/admin",
betterAuthAdmin({
authUrl: process.env.AUTH_URL || "http://localhost:3000",
title: "My App Admin",
})
);
// Start server
app.listen(3000, () => {
console.log("🚀 Server: http://localhost:3000");
console.log("📊 Admin: http://localhost:3000/admin");
});
adminUserIds can access admin featurestrustedOrigins is properly configuredMIT
Contributions are welcome! Please open an issue or submit a pull request.
FAQs
Admin Dashboard for Better Auth - Manage users, organizations, and sessions
The npm package better-auth-admin receives a total of 29 weekly downloads. As such, better-auth-admin popularity was classified as not popular.
We found that better-auth-admin demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.