Performance: Revalidation after mutations
This affects how quickly the UI updates after data changes and how much the page load and interaction responsiveness are impacted.
await fetch('/api/update', { method: 'POST', body: JSON.stringify(data) }); revalidate('routeId');
await fetch('/api/update', { method: 'POST', body: JSON.stringify(data) }); window.location.reload();
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Full page reload after mutation | High (all nodes re-created) | Multiple (full page) | High (full repaint) | [X] Bad |
| Targeted route revalidation after mutation | Low (only affected nodes) | Single or few | Low (partial repaint) | [OK] Good |
const revalidator = useRevalidator();
async function handleUpdate() {
await fetch('/api/update', { method: 'POST' });
revalidator.revalidate();
}
handleUpdate();
handleUpdate runs?const revalidator = useRevalidator();
async function saveData() {
await fetch('/api/save', { method: 'POST' });
revalidator();
}
Pass the test and this pattern moves unknown