React Server Actions - Form Handling
When to use this skill
- Handling form submissions in Next.js 14+ applications
- Performing server-side data mutations without API routes
- Implementing progressive enhancement for forms
- Creating actions that work without client-side JavaScript
- Validating form data securely on the server
- Revalidating Next.js cache after data mutations
- Handling file uploads with server-side processing
- Implementing optimistic UI updates with useOptimistic
- Building accessible forms with server-first architecture
- Integrating with database operations directly
- Managing form state with useFormState hook
- Creating secure mutations with server-only code
When to use this skill
- Implementing forms, mutations in Next.js App Router.
- When working on related tasks or features
- During development that requires this expertise
Use when: Implementing forms, mutations in Next.js App Router.
Server Action
```typescript 'use server';
export async function createPost(formData: FormData) { const title = formData.get('title'); await db.post.create({ data: { title } }); revalidatePath('/posts'); } ```
Scan to join WeChat group