svelte-navigator
svelte-navigator copied to clipboard
how do you handle 404
How do you do a 404 page for routes that don't exist?
I"ve tried a Route with no path (just as svelte-routing suggest) with no success
<Router>
<Route path="blog">
<Blog />
</Route>
<!-- ... the rest of your routes -->
<Route>
<!-- Your 404 component -->
<NotFound />
</Route>
</Router>
any idea?
Try using a wildcard: <Route path="*">...</Route>.
this is how i do in my project, not very perfect but works well
<Route path="/customers/:id/*" let:params>
{#await pb.records.getOne('customers', params.id) then record}
<Router>
<Route path="/">
<ViewCustomer {record}/>
</Route>
<Route>
<NotFound/>
</Route>
</Router>
{:catch error}
<NotFound/>
{/await}
</Route>