Search code examples
routessingle-page-applicationgithub-pagessveltesvelte-3

Routes not displaying on Refresh on Deploying Svelte App on Github pages


I was looking for a fix to "refresh doesn't work on components" issue. I found that it works by adding -s in package.json as mentioned here https://github.com/EmilTholin/svelte-routing/issues/32#issuecomment-495923463.

BUT when I deployed my app, I found that it does NOT work in the production build. Any idea why so?

I just want that my Svelte SPA pages do refresh when I do it.


Solution

  • I found that by creating a 200.html file (which basically has same content as index.html), it all works. Add that file to your production build folder.

    As mentioned by @rixo as well, it is not documented (just 404.html, they must have added 200.html recently), but that's how you tell gh pages to send the index to any request for an unknown page.