ServerAction
Import path
ts
import { createServerAction, createServerActionFactory } from '@azure-net/kit';TypeScript signatures
ts
createServerAction<T, I extends Record<string, unknown> = Record<string, unknown>>(
factory: (args: {
context: RequestEvent;
utils: { fail: typeof fail; redirect: typeof redirect; error: typeof error };
} & I) => T,
inject?: I
): () => T
createServerActionFactory<I extends Record<string, unknown>>(inject: I):
<T>(factory: (args: { context: RequestEvent; utils: Utils } & I) => T) => () => TWhat it accepts and returns
- Accepts a server factory callback (and optional injected dependencies).
- Returns callable action function for
+page.server.ts/ SvelteKit actions. - Throws on client usage.
Interaction map
- Common pattern: inject
createAsyncHelpersandparseErrorinto server action factory. - This makes server actions and presenters share the same async/error behavior.