svelte-navigator icon indicating copy to clipboard operation
svelte-navigator copied to clipboard

how do you handle 404

Open giosifelis opened this issue 4 years ago • 2 comments

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?

giosifelis avatar Sep 08 '21 18:09 giosifelis

Try using a wildcard: <Route path="*">...</Route>.

iluuu1994 avatar Sep 14 '21 08:09 iluuu1994

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>

eslym avatar Oct 21 '22 04:10 eslym