adapter-static doesn't work with dynamic routes
See original GitHub issueDescribe the bug
SvelteKit built using adapter-static with dynamic routes simply does not work on S3 (static hosting) and github pages.
When you start your site’s journey from / and then navigate using links to a dynamic route (i.e. /s/x/y), it works.
However if you directly try and go to /s/x/y (or alternatively refresh the page), you get a 404 page.
Is there any way to make the site work on s3 or github pages?
Or is dynamic routing with static-adapter not feasible?
Perhaps an option to make sveltekit use #-based routing.
Reproduction
Create any site with dynamic routes and run it on s3.
Logs
No response
System Info
s3
Severity
blocking all usage of SvelteKit
Additional Information
No response
Issue Analytics
- State:
- Created 2 years ago
- Comments:14 (8 by maintainers)
Top Results From Across the Web
How do dynamic routes work with adapter-static? : r/sveltejs
So nginx would receive the request, if it doesn't find/match a static file with that name, it serves up index.html which svelte handles...
Read more >SvelteKit static folder path doesn't work on dynamic routes
I'm using SvelteKit in my __layout.svelte . I've got like: <img src="./logo.svg" alt="logo" />. It works fine with "normal" page like about, ...
Read more >Configuration • Docs • SvelteKit
import adapter from '@sveltejs/adapter-auto'; ... default "static" ... non-dynamic routes (i.e. pages with no [parameters] , because SvelteKit doesn't know ...
Read more >Routing in Next.js – How to Set Up Dynamic Routing with Pre ...
❗How does getStaticProps() work? ... In the case of dynamic routes, however, Next.js doesn't know by itself which paths to pre-render.
Read more >Routing - Remix
Dynamic Segment - A segment of the route path that is parsed from the URL and ... ability to load data for the...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

Github Pages solution is a really hacky one, so if you can help it, don’t use it. And you’re probably better of with Cludflare Pages, Vercel, Netlify. And if you want to have something like S3 (and cheaper) then you can use BunnyCDN Edge Storage (read this article https://bunny.net/blog/host-your-frontend-applications-on-the-edge/ on their blog) (I don’t have any affiliation with them, I just use them)
And for all of these you DO need to use
fallbackoption for adapter config. Hope that helpsAs for the Github Pages, natively they don’t support SPAs, but there is hacky workaround https://github.com/rafgraph/spa-github-pages essentially you create
404.htmlfile inside static folder with this content:and in the
app.htmlyou add this before%svelte.body%(that’s really important):or simpler option is to JUST set
fallbackadapter option to404.htmlIt actually is better, but obviously for both of these options every request will return status code of 404 for real request which is really bad for SEO