docs/content/docs/infrastructure/plugins/dashboard.mdx
The Dashboard plugin is the core connection between your Better Auth instance and Better Auth Infrastructure. It powers the web dashboard with real-time data, tracks user activity, and enables admin APIs.
import { betterAuth } from "better-auth";
import { dash } from "@better-auth/infra";
export const auth = betterAuth({
plugins: [
dash(),
],
});
| Option | Type | Description |
|---|---|---|
apiUrl | string | Better Auth Infrastructure API URL |
kvUrl | string | KV store URL for caching |
apiKey | string | Your API key for authentication |
activityTracking | object | Activity tracking configuration |
Track when users were last active in your application. When enabled, a lastActiveAt field is automatically updated on user activity.
dash({
apiKey: process.env.BETTER_AUTH_API_KEY,
activityTracking: {
enabled: true,
updateInterval: 300000, // Update interval in ms (default: 5 minutes)
},
}),
When activity tracking is enabled, the plugin adds a field to your user schema:
user: {
fields: {
lastActiveAt: {
type: "date",
},
},
}
Make sure to run database migrations after enabling activity tracking.
import { createAuthClient } from "better-auth/client";
import { dashClient } from "@better-auth/infra/client";
export const authClient = createAuthClient({
plugins: [dashClient()],
});
dashClient({
resolveUserId: ({ userId, user, session }) => {
return userId || user?.id || session?.user?.id;
},
}),
Once dash() is active, the Better Auth Infrastructure dashboard gives you:
Always set an API key — without it, the plugin cannot communicate with the infrastructure API.
Use activity tracking wisely — the update interval affects database writes. For high-traffic apps, consider a longer interval.
Monitor audit log retention — different plans have different retention periods. Check your plan limits.
Secure your endpoints — dashboard endpoints require authentication. Make sure your dashboard users have appropriate permissions.