0Pricing
Sveltejs Academy · Lesson

error() and redirect() Helpers

Throw typed errors and redirects from load functions and actions.

Two Built-In Helpers

error() and redirect() from @sveltejs/kit handle the two main user-facing branches.

error Helper

Throws a structured error with status and message.

import { error } from "@sveltejs/kit";
error(404, "Not found");

All lessons in this course

  1. +error.svelte for Custom Error Pages
  2. Expected vs Unexpected Errors
  3. error() and redirect() Helpers
  4. Error Pages in Nested Layouts
← Back to Sveltejs Academy