/** * Next.js 16 - Server Actions for Form Handling * * This template shows comprehensive Server Actions patterns including: * - Basic form handling * - Validation with Zod * - Loading states * - Error handling * - Optimistic updates * - File uploads */ 'use server' import { z } from 'zod' import { revalidateTag } from 'next/cache' import { redirect } from 'next/navigation' // ============================================================================ // Example 1: Basic Server Action // ============================================================================ export async function createPost(formData: FormData) { const title = formData.get('title') as string const content = formData.get('content') as string // Save to database await fetch('https://api.example.com/posts', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ title, content }), }) // Revalidate cache revalidateTag('posts', 'max') // Redirect to posts list redirect('/posts') } // Basic form component export function CreatePostForm() { return (