Skip to content

feat(react-best-practices): add Server Action & Form pattern rules - #192

Open
mvanhorn wants to merge 1 commit into
vercel-labs:mainfrom
mvanhorn:osc/feat-server-action-form-rules
Open

feat(react-best-practices): add Server Action & Form pattern rules#192
mvanhorn wants to merge 1 commit into
vercel-labs:mainfrom
mvanhorn:osc/feat-server-action-form-rules

Conversation

@mvanhorn

Copy link
Copy Markdown
Contributor

Summary

Adds 5 new rules to the Server-Side Performance and Re-render Optimization categories covering Server Action and Form patterns.

New rules

  • server-useoptimistic - Use useOptimistic for instant UI feedback on mutations (HIGH)
  • server-action-revalidation - Granular cache revalidation after mutations (HIGH)
  • server-action-error-handling - Return error state instead of throwing (MEDIUM-HIGH)
  • server-progressive-enhancement - Forms that work without JavaScript (MEDIUM)
  • rerender-useformstatus - Pending state via useFormStatus without prop drilling (MEDIUM)

Why these rules

The skill has 8 server- rules but only server-auth-actions.md touches Server Actions directly (covering authentication). Server Actions are the primary mutation mechanism in Next.js App Router, and the patterns above are the most common sources of bugs and poor UX:

  • Waiting for server response before updating UI (useOptimistic fixes this)
  • Using revalidatePath('/') instead of granular revalidateTag after mutations
  • Throwing errors in actions instead of returning error state (kills the form UI)
  • Using onClick handlers instead of form actions (breaks without JS)
  • Prop drilling pending state instead of using useFormStatus

Each rule follows the existing _template.md format with incorrect/correct TypeScript examples and references to React/Next.js docs.

Complements PR #62 (useActionState) - these rules cover different aspects of the Server Action lifecycle.

Changes

  • 5 new rule files in skills/react-best-practices/rules/
  • Updated SKILL.md Quick Reference to list new rules (64 -> 69 rules)

This contribution was developed with AI assistance (Claude Code).

@vercel

vercel Bot commented Mar 22, 2026

Copy link
Copy Markdown

@mvanhorn is attempting to deploy a commit to the Vercel Team on Vercel.

A member of the Team first needs to authorize it.

Add 5 new rules covering Server Action and Form patterns:
- server-useoptimistic: instant UI feedback with useOptimistic (HIGH)
- server-action-revalidation: granular cache invalidation (HIGH)
- server-action-error-handling: return error state, don't throw (MEDIUM-HIGH)
- server-progressive-enhancement: forms that work without JS (MEDIUM)
- rerender-useformstatus: pending state without prop drilling (MEDIUM)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@mvanhorn
mvanhorn force-pushed the osc/feat-server-action-form-rules branch from d08178b to dfca54d Compare August 14, 2026 04:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant