Skip to content

createAdminAction

createAdminAction(config, tableMetas): (request) => Promise<Response | AdminActionResult>

Defined in: packages/admin/src/action.ts:121

Create an admin action function from config and introspected table metadata.

The returned action handles all admin mutations: record create, update, delete, role assignment/removal, impersonation start/stop, and custom row actions. It reads the _action field from the submitted FormData to dispatch to the appropriate handler.

Like the loader, it guards access using the auth adapter and creates a permission-scoped DB instance per request.

Use this instead of createAdmin when you need server/client code splitting.

AdminConfig

The admin configuration (same object passed to createAdmin).

AdminTableMeta[]

Table metadata from introspectSchema.

An async function that takes a Request and returns an AdminActionResult or a Response (for impersonation redirects).

(request): Promise<Response | AdminActionResult>

Request

Promise<Response | AdminActionResult>

app/admin.server.ts
import { createAdminAction, introspectSchema } from "@cfast/admin";
import * as schema from "~/schema";
const tableMetas = introspectSchema(schema);
export const adminAction = createAdminAction(config, tableMetas);