Skip to content

DashboardWidget

DashboardWidget = { label: string; table: string; type: "count"; where?: Record<string, unknown>; } | { label: string; limit?: number; table: string; type: "recent"; }

Defined in: packages/admin/src/types.ts:235

A widget definition for the admin dashboard.

Widgets are rendered on the admin index page. The "count" type shows a stat card with the total number of records. The "recent" type shows a list of the most recent records from a table.

{ label: string; table: string; type: "count"; where?: Record<string, unknown>; }

label: string

Display label for the stat card.

table: string

The Drizzle table name to count records from.

type: "count"

Renders a count stat card for the given table.

optional where: Record<string, unknown>

Optional filter conditions applied before counting.

{ label: string; limit?: number; table: string; type: "recent"; }

label: string

Display label for the recent items section.

optional limit: number

Maximum number of recent records to show. Defaults to 5.

table: string

The Drizzle table name to fetch recent records from.

type: "recent"

Renders a list of recent records from the given table.

const widgets: DashboardWidget[] = [
{ type: "count", table: "users", label: "Total Users" },
{ type: "count", table: "posts", label: "Published Posts", where: { published: true } },
{ type: "recent", table: "posts", label: "Recent Posts", limit: 5 },
];