Error Pages in Sveltekit
Recently I’ve been playing with Svelte. As a relatively new guy to the web development field, I can certainly certify svelte as one of the easiest frameworks to get the hang of. And if you don’t know, SvelteKit is the officially preferred method for creating Svelte Apps.
The default error pages in SvelteKit are kind of basic. Something like I’ve shown below.
Not found: /dfkdf
Error: Not found: /dfkdf
// continues here....
This is helpful while our app is in development, but our end users were gonna see this page, they’ll never know what went wrong.
SvelteKit makes it easy for implementing custom Error pages.
All we have to do is, create a file named
__error.svelte in the routes folder.
Anything we put inside this file will be shown on pages with an error instead of the default error page.
For example, we can show Page Not Found in our error pages with the below code.
<!-- __error.svelte -->
Page Not Found
I hope you found something useful here. If you found some errors or a typo, or you wanna just talk contact me 😊
Join my email list to get the latest posts and updates.