Redirect after form action
2023-01-24When handling a SvelteKit form action, if you need to redirect to another route, this can be done by using throw redirect .
For example, if a response back from an API call for authentication doesn’t have any errors, we can redirect the user to the dashboard or return the error message.
if (response.error) {
return {
error: response.error
}
} else {
throw redirect(303, '/dashboard')
}