svelte-spa-router-example Svelte Themes

Svelte Spa Router Example

Illustrating a possible bug in the router

Problem

I would expect that this link would route to the <NotFound/> component, but it doesn't. This does because the hash-bang is already in the route.

To Re-create Locally

Setup

git clone https://github.com/LaughingBubba/svelte-spa-router-example.git
cd svelte-spa-router-example
npm i

Run using sirv-cli

npm run dev

Then navigate to http://localhost:5000/ and type should-be-router404 at the end of the URL and press enter. It just remains on the route.

If you go to http://localhost:5000/#/should-be-router404 you'll get routed to the <NotFound/> component as expected.

Run using serve

If you happen to have serve installed globally:

serve ./public

This demonstrates the problem a little better as when you navigate to http://localhost:5000/should-be-router404 you fall through to serve's own 404.

Top categories

Loading Svelte Themes