Build Your WorkspaceActions
Custom Actions
Define custom actions with forms, confirmation dialogs, and server-side handlers.
Custom actions extend the admin with domain-specific operations — bulk status changes, exports, notifications, or any workflow step.
Defining Custom Actions
Custom actions can be added to collections with forms and handlers:
// Collection with custom action
.admin(({ c }) => ({
label: { en: "Appointments" },
actions: [
{
id: "mark-completed",
label: { en: "Mark as Completed" },
icon: c.icon("ph:check-circle"),
handler: async ({ ids, collections }) => {
for (const id of ids) {
await collections.appointments.update({
where: { id },
data: { status: "completed" },
});
}
},
},
{
id: "cancel-with-reason",
label: { en: "Cancel Appointment" },
icon: c.icon("ph:x-circle"),
confirm: { en: "Are you sure you want to cancel?" },
form: {
reason: {
type: "textarea",
label: { en: "Cancellation Reason" },
required: true,
},
},
handler: async ({ ids, formData, collections }) => {
for (const id of ids) {
await collections.appointments.update({
where: { id },
data: {
status: "cancelled",
cancellationReason: formData.reason,
cancelledAt: new Date(),
},
});
}
},
},
],
}))Action Options
| Option | Type | Description |
|---|---|---|
id | string | Unique identifier |
label | string | i18n | Button label |
icon | Icon | Button icon |
confirm | string | i18n | Confirmation dialog text |
form | object | Form fields shown before execution |
handler | function | Server-side handler |
bulk | boolean | Available as bulk action in list view |
Related Pages
- Built-in Actions — Default CRUD actions
- Routes — Server-side route logic