Skip to content

TypeScript load function example #2712

@benblazak

Description

@benblazak

Describe the problem

It took me a long time to figure out how to write a TypeScript load function for __error.svelte

Describe the proposed solution

Include an example :)

import type { ErrorLoadInput, LoadOutput } from "@sveltejs/kit";
export async function load({
  error,
  status,
}: ErrorLoadInput): Promise<LoadOutput> {
  return {
    props: {
      title: `${status}: ${error.message}`,
      stack: error.stack,
    },
  };
}

Alternatives considered

Don't include an example :(

Importance

nice to have

Additional Information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    documentationImprovements or additions to documentationp2-nice-to-haveSvelteKit cannot be used by a small number of people, quality of life improvements, etc.types / typescript

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions