Performance: Redirect from actions
MEDIUM IMPACT
This affects page load speed and user interaction responsiveness by controlling navigation timing after form submissions or actions.
import { redirect } from '@sveltejs/kit'; export const actions = { default: async ({ request }) => { // process form data throw redirect(303, '/new-page'); } };
export const actions = { default: async ({ request }) => { // process form data return { success: true }; } }; // Redirect done client-side after action response
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Client-side redirect after action | Full DOM load before redirect | Multiple reflows due to page load then redirect | High paint cost due to double rendering | [X] Bad |
| Server-side redirect from action | No DOM load for original page | No reflows before redirect | Minimal paint cost, direct navigation | [OK] Good |