v2.5.0
Typed actions in the SDK
defineAction infers input and output types from your schema, end to end.
defineAction takes a Zod or Valibot schema and infers the input type in the UI and the handler. No more hand-written types that drift.
npm
npm install @forgekit/sdk@2.5.0bun
bun add @forgekit/sdk@2.5.0pnpm
pnpm add @forgekit/sdk@2.5.0import { defineAction } from "@forgekit/sdk";
import { z } from "zod";
export const refundOrder = defineAction({
input: z.object({ orderId: z.string(), amountCents: z.number().int() }),
async run({ input, db }) {
return db.refunds.create({ data: input });
},
});
- Inputs are validated on the server before
runis called - Validation errors show next to the matching form field