Server functions
Run a workflow declared with on: { call: true } for the signed-in user and get its JSON return value. Third-party keys stay on the server.
app.call
app.callmethod
Run the app's server function name (a contract workflow with on: { call: true }) for the signed-in user and get its JSON return value. It runs server-side, so third-party APIs (ctx.http.fetch) and keys (ctx.secrets) never reach the browser.
app.call<T = unknown>(name: string, input?: Record<string, unknown>): Promise<T>Parameters
| Name | Type | Description |
|---|---|---|
namerequired | string | The workflow id. |
inputoptional | Record<string, unknown> | A JSON object (at most 64 KB) the function reads as its event payload. |
- Returns
- The function's return value, typed as T (null when it returns nothing).
- Errors
- "server functions aren't available in this preview" without a runtime; "app.call needs the function's name".
- "Sign in to use this." (SIGN_IN_REQUIRED), "Only <roles> may use this." (ROLE_FORBIDDEN), FUNCTION_NOT_FOUND, NOT_A_FUNCTION.
- The function's own error message (FUNCTION_FAILED), "\"<name>\" didn't finish within 35s." (FUNCTION_TIMEOUT), FUNCTION_BUSY (more than 4 calls in flight), QUOTA_EXCEEDED.
- Permissions
- The function's ctx.db is scoped to the caller's row-level security and live role. A function declares who may call it with roles; public functions accept signed-out callers.
const quote = await app.call<{ total: number; currency: string }>("shipping-quote", {
country: form.country,
weightKg: Number(form.weight),
});
setTotal(`${quote.total} ${quote.currency}`);Source: packages/appkit/src/kits/primitives/app-handle.ts:198