Svelte · Middle · Question 40 of 75
How do you redirect from a server load or action?
import { redirect } from "@sveltejs/kit";
if (!locals.user) redirect(303, "/login");- ✓Correct answer: Call
redirect(status, location)from@sveltejs/kit - 2Return
{ redirect: "/login" } - 3Set
window.location
Explanation
Use 303 after a POST so the browser follows with GET. Don't call redirect inside a try block that swallows it.