BETTER-AUTH. UI
Plugins

Dash

Add personal activity and organization audit logs from Better Auth Infrastructure Dash.

The Dash integration adds Activity tabs to personal settings, organization settings, and the Admin user inspector. It reads audit logs through the public dashClient() API from @better-auth/infra.

Organization owners and admins see organization-wide activity. Other members see only their own activity in that organization. Every organization query uses the organization ID from the current route.

Setup

Configure Dash on the server

Install @better-auth/infra, then add dash() to Better Auth. Dash records supported authentication and organization events automatically.

lib/auth.ts
import { dash } from "@better-auth/infra"
import { betterAuth } from "better-auth"

export const auth = betterAuth({
  plugins: [
    dash({
      apiUrl: process.env.BETTER_AUTH_API_URL,
      kvUrl: process.env.BETTER_AUTH_KV_URL,
      apiKey: process.env.BETTER_AUTH_API_KEY
    })
  ]
})

See the Dash plugin guide for infrastructure setup and available events.

Add the client plugin

lib/auth-client.ts
import { dashClient } from "@better-auth/infra/client"
import { createAuthClient } from "better-auth/client"
import { organizationClient } from "better-auth/client/plugins"

export const authClient = createAuthClient({
  plugins: [organizationClient(), dashClient()]
})

Install the registry item

bunx shadcn@latest add @better-auth-ui/dash

This installs the activity views, local plugin factory, and required shadcn/ui components.

Register the UI plugin

components/providers.tsx
import { AuthProvider } from "@/components/auth/auth-provider"
import { dashPlugin } from "@/lib/auth/dash-plugin"
import { organizationPlugin } from "@/lib/auth/organization-plugin"

<AuthProvider
  authClient={authClient}
  navigate={navigate}
  plugins={[organizationPlugin(), dashPlugin()]}
>
  {children}
</AuthProvider>

Both personal and organization activity are enabled by default. Set organization: false if the app does not use Better Auth organizations.

Static routes

The plugin adds one static path named activity. Its default segment is activity, which produces routes such as /settings/activity and the matching organization activity path.

It does not use query parameters, nested plugin routes, or a catch-all route. Add the segment to both static path lists when the application validates or generates settings and organization routes.

route-paths.ts
import { viewPaths } from "@better-auth-ui/core"

import { dashPlugin } from "@/lib/auth/dash-plugin"
import { organizationPlugin } from "@/lib/auth/organization-plugin"

const activityPath = dashPlugin({ path: "activity" }).viewPaths.settings.activity

export const validSettingsPaths = [
  ...Object.values(viewPaths.settings),
  ...Object.values(organizationPlugin().viewPaths.settings ?? {}),
  activityPath
]

export const validOrganizationPaths = [
  ...Object.values(organizationPlugin().viewPaths.organization ?? {}),
  activityPath
]

Use the same Dash options in the provider and route configuration when you customize the segment.

Admin user activity

If the Admin integration is present, Dash adds an Activity tab to its user inspector. The tab calls getAllAuditLogs({ userId }) for the selected user.

Dash authorizes this endpoint for organization owners and admins. A Better Auth application-admin role does not grant Dash access by itself.

Set admin: false on dashPlugin() to remove this inspector tab.

Access and privacy

  • Personal settings call getAuditLogs for the signed-in user.
  • Organization settings check the member role for the explicit organization ID.
  • Owners and admins call getAllAuditLogs for that organization.
  • Other members call getAuditLogs with the organization filter.
  • IP addresses are hidden by default. Set showIpAddress: true only when your privacy policy permits it.

Retention comes from Dash

The empty state says that no retained activity matches the view. It does not claim that an event never occurred.

Headless hooks

import {
  useDashAllAuditLogs,
  useDashAuditLogs,
  useDashUserAuditLogs
} from "@better-auth-ui/react/plugins/dash"

The core package also exports query option factories and ensure, prefetch, and fetch helpers from @better-auth-ui/core/plugins/dash.

Copied files

  • src/lib/auth/dash-plugin.ts
  • src/components/auth/dash/activity.tsx

Options

Prop

Type

Localization

Prop

Type

Last updated on

On this page