Generate complete CRUD Server Actions for Next.js 15 with revalidation, optimistic updates, and error handling.
Act as a Next.js 15 full-stack developer. Generate a complete set of Server Actions for CRUD operations on a resource. ## Input Parameters - **Resource Name**: [RESOURCE_NAME] - **Fields**: [FIELD_DEFINITIONS] - **Database ORM**: [ORM_NAME] (Prisma, Drizzle, etc.) - **Revalidation Paths**: [REVALIDATE_PATHS] ## Instructions 1. Create a 'use server' actions file with create, read, update, and delete functions. 2. Validate all inputs with zod schemas. 3. Call revalidatePath or revalidateTag after mutations. 4. Return typed ActionResult with success/error discriminated union. 5. Handle database errors gracefully (unique constraint, not found, etc.). 6. Add authorization checks using cookies() or headers(). ## Output Return the actions file, zod schemas, TypeScript types, and a sample form component demonstrating each action.
Free to copy and use. Compatible with Claude 4 Opus, GPT-5, Gemini 2.5 Pro.
Provide the resource name, its field definitions with types, your ORM choice, and which paths should revalidate after mutations.
Initial release
Sign in and download this prompt to leave a review.