Use svelte-routing with /#/ as basepath

This issue has been tracked since 2021-02-17.


sorry if this issue is just a dumb newbie question.

I want to use svelte-routing without SSR on netlify (so I can't configure the server by my own).
The problem at the moment is that when I goto the normal without any path ( the svelte app is loaded normaly. But as soon as I directly goto the domain with a path ( netlify checks if there is the directoy "mypath" and throws an error, because the is none.

You can checkout this issue here: where you can't access directly

I wanted to solve this issue by adding a "/#/" before any fronentrouted path (, so it's clear for netlify that I still want to access the index.html with my svelte app.

Whenever I try to set "/#/" as the basepath, the app just won't work and doesn't display the component behind the corresponding route.
I even tried this, but it didn't work:
navigate("/#/mypath"); with <Route path="/#/mypath" component="{ComponentXYZ}">

Does anyone have any idea about this issue? I guess I'm not the first one with this topic?

Thank you so much and have a nice day!

mefechoel wrote this answer on 2021-02-18

Unfortunately, svelte-routing does not support hash based routing, which would be what you are looking for. I'm sure there is a way to configure netlify to work with a single page app (history based routing), though.
Alternatively you could try a different router. svelte-spa-router is quite popular and is hash based. If you don't want to give up svelte routing's api you can checkout svelte-navigator's custom hash history example. When v4 comes out it will support hash navigation out of the box.

heikodede wrote this answer on 2021-02-18

Thank you for your answer and patience. This really helped and I'm looking for an option to solve it by configuring netlify. Have a nice day!

If anyone else finds this issue via search and is looking for an answer: Here is the solution!
Just create a file named "_redirects" with this content /* /index.html 200

More Details About Repo
Owner Name EmilTholin
Repo Name svelte-routing
Full Name EmilTholin/svelte-routing
Language JavaScript
Created Date 2017-11-28
Updated Date 2022-12-03
Star Count 1711
Watcher Count 21
Fork Count 151
Issue Count 59


Issue Title Created Date Updated Date