adapter-static only
SvelteKit can deploy to many runtimes via adapters. StaticHost speaks one dialect: files on disk. Use @sveltejs/adapter-static. If you are on adapter-node, adapter-vercel, or similar, this host is the wrong target unless you switch adapters and accept static constraints.
StaticHost does not run vite build for you. nginx is try_files $uri $uri/ =404 with no SPA fallback. HTTPS preview is immediate; custom domain certificates follow DNS verification. Plans: Starter $9, Pro $30, Scale $65, Business $130 after a ~1 day trial. No forever-free, cPanel, email, built-in CDN product, or PHP.
Install and configure the adapter
npm install -D @sveltejs/adapter-static
svelte.config.js:
import adapter from '@sveltejs/adapter-static'
import { vitePreprocess } from '@sveltejs/vite-plugin-svelte'
/** @type {import('@sveltejs/kit').Config} */
const config = {
preprocess: vitePreprocess(),
kit: {
adapter: adapter({
pages: 'build',
assets: 'build',
fallback: undefined, // do not invent SPA fallback expectations for StaticHost
precompress: false,
strict: true,
}),
paths: {
base: '', // root hosting
},
},
}
export default config
About fallback: Some static hosts use a fallback HTML file so client routers can handle missing paths. StaticHost will not rewrite unknown URLs to that file. Setting a fallback may emit an extra HTML document, but nginx still returns 404 for unknown paths. Prefer prerendering every route you care about. Do not document a fictional rewrite.
Prerender
Enable prerender so routes become files:
// +layout.js or +page.js
export const prerender = true
Dynamic routes must be enumerable at build time (entries / prerender.entries). If a route cannot be prerendered, it will not exist as a file and will 404 on StaticHost. strict: true fails the build when pages are not accounted for—use that failure; it is cheaper than a production 404.
Build and zip
npm ci
npm run build
ls build
cd build && zip -r ../svelte-site.zip .
Deploy via zip or GitHub artifact branch—no remote npm. Host a dist folder online, zip a static site without 404, git deploy a static site.
Worked example: marketing site with a dynamic blog slug list
// src/routes/blog/[slug]/+page.js
export const prerender = true
/** @type {import('./$types').EntryGenerator} */
export function entries() {
return [
{ slug: 'launch' },
{ slug: 'pricing-change' },
]
}
npm run build
find build -path '*blog*' -type f
If launch is missing from find, it will not be on StaticHost either. Fix entries() before you upload. Deploy, open HTTPS preview, paste /blog/launch into the address bar (hard navigation)—expect 200. Paste /blog/does-not-exist—expect 404, which is correct.
Env
Use $env/static/public / PUBLIC_ variables at build time. Rebuild when values change. Staging on Pro ($30/mo) helps when PUBLIC_API_URL differs between QA and production.
Non-Kit Svelte
A plain Vite + Svelte SPA (not SvelteKit) follows the Vite + SPA path: dist/, hash router recommended.
When not to use StaticHost for Svelte
- You need server form actions /
+page.server.jsin production. - You need streaming SSR on each request.
- You set
fallback: 'index.html'and expect deep links to work here—they will not. - You depend on
adapter-nodefeatures.
Verify
HTTPS preview immediately. Visit each prerendered route by pasting the URL. Confirm assets under _app/ (or current Kit asset layout) return 200. Roll back on bad releases. Custom domain certificate after DNS verifies—static hosting with a custom domain.
Failure table (SvelteKit static)
| Symptom | Likely cause | Fix |
|---|---|---|
| Build warns about unprerenderable pages | Missing prerender / entries | Mark pages; enumerate dynamic params |
| Deep link 404 | Assumed fallback rewrite | Prerender that path; do not rely on fallback |
| Assets 404 under wrong base | paths.base set for GitHub Pages | Use base: '' for root hosting |
| Form action 500/404 | Server actions with static adapter | Third-party forms or external API |
Old PUBLIC_ values in UI | Stale build | Rebuild with new env; redeploy |
Extra procedure: SvelteKit → StaticHost release gate
- Confirm
adapter-staticwithstrict: trueandfallback: undefined(or otherwise no rewrite fantasies). npm ci && npm run buildon CI or laptop—never on StaticHost.find build -name index.htmland reconcile with your sitemap mentally.- Zip
build/contents; deploy; HTTPS preview hard-navigation for each important path. - Curl a missing path; confirm 404 (proves
try_files $uri $uri/ =404). - Grep for mixed
http://if you are about to attach a domain—SSL. - DNS → verification → certificate only after preview is green.
- Keep Pro staging when
PUBLIC_differs across environments. - Document plan tier (Starter $9 / Pro $30 / Scale $65 / Business $130) and non-features (no forever-free, email, cPanel, CDN product) for the team.
If server features creep back into the roadmap, move adapters/hosts deliberately—when static hosting is the wrong choice—instead of bolting Node onto a file platform.
Second worked sketch: docs site with only prerendered leaves
You maintain /docs, /docs/install, and /docs/api/auth. Each route exports prerender = true. There is no [slug] wildness—just leaf pages. Build output contains matching directories. StaticHost serves them like any Hugo site. You still do not get SPA fallback for a client-only /docs/api/auth/edit screen you forgot to prerender; paste-test would catch it. Roll back if a Kit upgrade changes asset paths and breaks _app/ URLs until you redeploy a fixed build.
Content collections and build-time data
Many SvelteKit sites load Markdown or CMS data in +page.js during prerender. That is compatible with StaticHost when every consumed path is known at build time. Fetch remote data in CI with stable credentials, fail the build if the CMS is unreachable, and only then upload build/. A host-side function that proxies the CMS on each request is not available here—and inventing fallback: 'index.html' will not create those pages either.
Version your entries() list or content glob so removing a slug also removes the file from the artifact; otherwise you may keep serving a stale HTML page until the next clean publish. After deploy, spot-check that deleted slugs 404 (correct) and that retained slugs 200 on hard navigation. Pair with deploy history so a bad content import can be rolled back while you fix the fetcher. Plans stay $9/$30/$65/$130 with a short trial; storage is rarely the issue for docs-sized Kit sites unless you vendor huge binaries into static/.
FAQ
Can I set fallback: 'index.html' and expect deep links to work?
Not on StaticHost. Unknown paths still 404. Prerender routes instead.
Does strict: true help?
It fails the build when pages are not accounted for—good for catching holes before upload.
Where do form actions go?
Server form actions need a non-static adapter. Use third-party forms or external APIs with static Kit.
Is build/ or dist/ correct?
With adapter-static defaults above, build/. Always list the directory your adapter emits.
Can I host Svelte 4 SPA without Kit?
Yes—Vite build output plus honest routing choices. See also static hosting for JavaScript apps.