Server Actions
Terra uses Next.js Server Actions for all data mutations.
Action Files
Common Patterns
Permission Check
ActionResult Pattern
Revalidation
Database Schema
Table reference
Authorization
Permission checks
Documentation Index
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
Reference for Terra’s server actions
Terra uses Next.js Server Actions for all data mutations.
| File | Purpose |
|---|---|
airtable.ts | Airtable OAuth and sync |
notifications.ts | Email/SMS sending |
insights.ts | Analytics queries |
applicants.ts | Applicant management |
status.ts | Submission status |
domains.ts | Custom domain config |
workspaces.ts | Folder management |
agencies.ts | Agency management |
form-versions.ts | Draft/publish |
webhooks.ts | Webhook config |
team.ts | Permissions |
settings.ts | Org settings |
"use server";
export async function updateSubmission(id: string, data: Data) {
const user = await requireAdmin(); // Throws if unauthorized
await supabaseAdmin
.from("form_submissions")
.update(data)
.eq("id", id);
await logAudit(user.id, "submission.updated", { id });
return { success: true };
}
type ActionResult<T> =
| { success: true; data: T }
| { success: false; error: string };
export async function createForm(data: FormData): Promise<ActionResult<Form>> {
try {
const user = await requireAdmin();
const form = await insertForm(data);
return { success: true, data: form };
} catch (error) {
return { success: false, error: error.message };
}
}
import { revalidatePath } from "next/cache";
export async function publishForm(id: string) {
await updateFormStatus(id, "published");
revalidatePath(`/forms/${id}`);
revalidatePath("/forms");
}
Was this page helpful?