VVibeFlui

Registry Handlers

Handlers execute actions.

In schemas, actions reference handlers by string key. The actual async function lives in the runtime registry.

Schema usage

schemas/users/user-actions.schema.ts

TS
export const usersSchema = {
  version: "1.0.0",
  resource: "users",
  actions: {
    create: {
      enabled: true,
      label: "Create user",
      icon: "lucide:plus",
      handler: "users.create"
    },
    delete: {
      enabled: true,
      label: "Delete",
      icon: "lucide:trash-2",
      variant: "danger",
      handler: "users.delete",
      confirm: true
    },
    row: [
      {
        key: "invite",
        label: "Invite",
        icon: "lucide:send",
        handler: "users.invite"
      }
    ]
  },
  registry: {
    actionHandlers: ["users.create", "users.delete", "users.invite"]
  }
} as const;

Runtime registry

lib/vibeflui/registry.ts

TS
import { createRegistry } from "@vibeflui/core";

export const registry = createRegistry({
  actionHandlers: {
    "users.create": async ({ values }) => {
      return {
        status: true,
        code: 200,
        message: `${String(values?.name ?? "User")} created`,
        data: values
      };
    },
    "users.delete": async ({ identityValue }) => {
      return {
        status: true,
        code: 200,
        message: `User ${String(identityValue)} deleted`
      };
    },
    "users.invite": async ({ row }) => {
      return {
        status: true,
        code: 200,
        message: `${String(row?.email ?? "User")} invited`
      };
    }
  }
});

Handler context

Handlers receive an execution context.

Context propertyPurpose
schemaNormalized schema.
actionResolved action config.
operationOperation name such as create, update, delete, or custom key.
rowCurrent row for row actions.
valuesCurrent form values for form actions.
queryQuery state for list operations.
endpointResolved endpoint if one exists.
fetcherFetch-like function when provided.
identityValueRow identity value resolved from identity.key.
paramsEndpoint placeholder values.
permissionContextRoles, permissions, user, or custom context.

actionHandlers vs handlers

Use actionHandlers for new documentation and examples.

The runtime also supports handlers as an alias during action execution and lifecycle hooks. Prefer actionHandlers for clarity.

lib/vibeflui/registry.ts

TS
export const registry = createRegistry({
  actionHandlers: {
    "users.approve": async () => ({ status: true, code: 200, message: "Approved" })
  }
});

Endpoint actions vs handler actions

Use endpoint actions when the schema only needs to call an API.

schemas/users/user-actions.ts

TS
export const archiveAction = {
  key: "archive",
  label: "Archive",
  endpoint: { url: "/api/users/:id/archive", method: "POST" },
  refreshOnSuccess: true
} as const;

Use handler actions when UI-specific runtime behavior is needed.

schemas/users/user-actions.ts

TS
export const inviteAction = {
  key: "invite",
  label: "Invite",
  handler: "users.invite"
} as const;

Backend responsibility

Handlers may call APIs, update local UI state, or return mock responses for local demos. They must not be treated as backend authorization. The backend still owns final security decisions.