Skip to content

createAdminLoader

createAdminLoader(config, tableMetas): (request) => Promise<AdminLoaderData>

Defined in: packages/admin/src/loader.ts:623

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

The returned loader handles all admin views: dashboard, table list, detail, create, edit, user list, and user detail. It guards access using the AdminAuthConfig.requireUser and AdminAuthConfig.hasRole callbacks, creates a permission-scoped DB instance via CreateDbFn, and parses the URL to determine which view data to fetch.

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 AdminLoaderData.

(request): Promise<AdminLoaderData>

Request

Promise<AdminLoaderData>

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