`+error.svelte` needs to have a `load` function
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 20.8k
- Forks
- 2.3k
- Avg merge
- 1d 16h
- Merged PRs (30d)
- 156
Description
Describe the problem
Previously error pages could have load functions, just like regular pages, from #5748 onwards that's no longer possible, the rationale given was that an error page doesn't really need a load function and a load function could potentially screw things up further.
But I think a very important and common scenario was overlooked: You might want to return data from the error page's load function that the layout will then consume, and just things of that nature in general.
So for instance:
error.ts:
export const load: ErrorLoad = () => {
return {
meta: {
title: "404 Not Found",
showFooter: false
}
};
};
This is actually very serious. I just realized there's no way of doing this right now, but it's needed in a lot of cases obviously. The current design doesn't provide any alternative.
Describe the proposed solution
Just allow error pages to have load functions like before please. You could then just simply point out in the docs that the load function of an error page must avoid doing anything that could potentially result in another error.
Alternatives considered
No response
Importance
i cannot use SvelteKit without it
Additional Information
No response
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by tracing the error-page handling changed in #5748 and inspect how error.ts and its surrounding layout currently receive data. Done means an error page can export a load function, return data consumed by the layout, and avoid breaking existing error handling.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- web-dev
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100