Changelog
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.0

bun

bun add @forgekit/sdk@2.5.0

pnpm

pnpm add @forgekit/sdk@2.5.0
import { 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 run is called
  • Validation errors show next to the matching form field