Performance: Server action in client components
MEDIUM IMPACT
This affects interaction responsiveness and network load by offloading logic to the server while keeping UI responsive.
import { serverAction } from './actions'; 'use client'; function Form() { const handleSubmit = async (e) => { e.preventDefault(); const result = await serverAction(); alert(result); }; return <form onSubmit={handleSubmit}><button type="submit">Submit</button></form>; } // serverAction is a server function called via Next.js server actions
function Form() { const handleSubmit = async (e) => { e.preventDefault(); // Client-side heavy logic const result = await heavyClientSideProcessing(); alert(result); }; return <form onSubmit={handleSubmit}><button type="submit">Submit</button></form>; }
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Client-side heavy logic | Minimal | 0 | Low | [X] Bad |
| Server action in client component | Minimal | 0 | Low | [OK] Good |