sveltejs / sveltejs/kit

error and fallback pages for init() hook

Open
#13,333 0 comments 3 reactions 0 assignees View on GitHub

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

I need to fetch my db before any single bit of my SvelteKit SPA can load, I currently use init() insidie hooks.client.ts but errors invoked using kit's error() aren't presented in either +error.svelte or error.html

Describe the proposed solution

I would like an optional fallback (while init() is awaited) and error page (when init() throws), ideally with our css files loaded (for styling). Currently, if there is an error a white screen is presented with no indication of what went wrong which is confusing to users.

Alternatives considered

Use root layouts for initial stuff but in my experience this has been clunky for init() stuff that needs to load once and requires extra conditional logic and I need separation of concerns. If there are other ways that I can handle this that I haven't considered or am not aware of do share!

Importance

would make my life easier

Additional Information

Router Mode: #hash
Adapter adapter-static

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by examining client initialization in hooks.client.ts and how errors are currently routed relative to +error.svelte and error.html. Compare the requested fallback while init() is awaited and error page when init() throws, including CSS loading, with the existing root-layout and adapter-static behavior; done means both states render a styled, informative page.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
frontend, web-dev
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.