Deploy SvelteKit Static Site on Hostinger with Namecheap and StackPath

by Fahim

Running a Node daemon just to serve a marketing site or personal blog is a waste of money and operational sanity. You don’t need a running server process, a PM2 config to babysit, or memory leaks to debug at 2 AM. If your pages don’t need dynamic server rendering on every hit, compile SvelteKit down to flat HTML, CSS, and JS, dump the files onto Hostinger, and let StackPath handle global edge delivery.

By default, SvelteKit assumes you want a running server via adapter-auto or adapter-node. Swapping to static prerendering drops response times to sub-50ms on cheap shared hosting while cutting your attack surface down to almost zero.

SvelteKit static build output displayed in a terminal during deployment
SvelteKit static build output displayed in a terminal during deployment

1. Swap SvelteKit to adapter-static

A fresh SvelteKit project starts with @sveltejs/adapter-auto. It tries to guess your target environment during build, but for raw files on Apache or LiteSpeed, you need the official static adapter.

Rip out the default adapter and install adapter-static:

npm uninstall @sveltejs/adapter-auto
npm install -D @sveltejs/adapter-static@2.0.3

Open your svelte.config.js and configure the static adapter. I set fallback: '404.html' so Hostinger serves an actual styled 404 page when someone hits a bad route:

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: '404.html', precompress: false, strict: true }) }
}; export default config;

Now tell SvelteKit to crawl and bake out every page. Drop a root layout config in src/routes/+layout.js (or +layout.ts):

export const prerender = true;
export const trailingSlash = 'always';

Pay attention to trailingSlash = 'always'. This forces SvelteKit to output about/index.html instead of about.html. Without this, Apache and LiteSpeed trip over directory paths without messy rewrite rules. Do it here and save yourself the headache.

2. Build and Verify the Static Output Locally

Before logging into Hostinger or touching DNS, run the build locally. If any of your routes fetch dynamic data without endpoints or use server-only modules, the prerender crawler will scream at you right here.

npm run build

Take a look inside your build/ directory. You should see a structure like this:

build/
├── _app/
│ ├── immutable/
│ │ ├── assets/
│ │ ├── chunks/
│ │ └── entry/
│ └── version.json
├── 404.html
├── index.html
└── about/ └── index.html

Everything in _app/immutable/ has a content hash baked into the filename. Per the MDN Cache-Control specifications, these files can sit in browser and CDN caches for up to a full year without any risk of serving stale code.

3. Configure Hostinger and Upload Files

Jump into Hostinger’s hPanel. Go to Websites, find your domain, and open the File Manager. You’ll be dumping everything directly into public_html.

Clicking around a web UI for every deploy gets old fast. If you have SSH access enabled on your plan, push updates with a quick rsync command:

rsync -avz --delete -e 'ssh -p 65002' build/ u123456789@your-server-ip:public_html/

We hit almost this exact same workflow when deploying an Astro static site on Hostinger. If SSH isn’t set up on your account, zip up the contents of your local build directory (not the folder itself), upload the archive via hPanel File Manager, and extract it inside public_html.

Next, drop a .htaccess file into public_html to give Hostinger’s LiteSpeed server sane routing and cache rules:

DirectoryIndex index.html # Handle missing URLs gracefully with custom 404
ErrorDocument 404 /404.html  # Immutable hashing for SvelteKit assets  Header set Cache-Control "max-age=31536000, public, immutable"  # HTML pages should revalidate quickly  Header set Cache-Control "max-age=0, no-cache, no-store, must-revalidate" 

4. Set Up Namecheap DNS Records

Now point your domain to the files. Head to your Namecheap dashboard, find your domain under the Domain List, hit Manage, and flip to the Advanced DNS tab.

You have two ways to route traffic here:

  • Point straight to Hostinger’s origin IP first (do this to get Hostinger’s free SSL certificate issued cleanly).
  • Point directly to StackPath’s edge IPs right away.

I always point to Hostinger first. It makes issuing the Let’s Encrypt cert in hPanel painless without failing HTTP-01 domain validation checks. If you’re not sure which record types to use on the apex domain, read through our comparison of A record vs CNAME on Namecheap DNS.

Set up your records in Namecheap according to the Namecheap Host Records guide:

  • Type: A Record | Host: @ | Value: YOUR_HOSTINGER_SERVER_IP | TTL: 5 min
  • Type: CNAME Record | Host: www | Value: yourdomain.com. | TTL: 5 min

Give DNS a few minutes to catch up. Load your site over HTTPS to confirm Hostinger is serving the static build properly before introducing the CDN layer.

5. Put StackPath CDN in Front of Hostinger

With the origin site working, StackPath handles global edge caching so visitors aren’t waiting on a single shared server in one geographic region.

  1. Log into StackPath and click Create Site.
  2. Type your domain name (e.g., example.com) and pick CDN.
  3. Set Origin Type to IP Address and plug in your Hostinger server IP.
  4. Set Origin Port to 443 and check Origin Connection Method: HTTPS.

Before you repoint public DNS, get an SSL cert running on the edge. You can issue a free Let’s Encrypt certificate right from the StackPath dashboard or upload a custom one. This prevents broken cert chains between the client, edge, and Hostinger. For a detailed walkthrough, check out our guide on end-to-end SSL with Namecheap, Hostinger, and StackPath.

Now configure custom EdgeRules to align with SvelteKit’s caching model. Go to CDN > EdgeRules > Add Rule.

Rule 1: Cache immutable assets aggressively for a full year.

  • If: URL Path matches wildcards /_app/immutable/*
  • Then: Override Cache TTL to 31536000 seconds (1 year)

Rule 2: Never cache HTML files at the edge so deploy updates show up immediately.

  • If: URL Path matches wildcards *.html OR URL Path ends with /
  • Then: Override Cache TTL to 0 seconds (Pass-through)

If you’re pulling custom fonts or icon SVGs across origins, be sure you know how to fix CORS errors on static assets in StackPath before flipping traffic.

Finally, head back to Namecheap Advanced DNS. Update your A Record to the StackPath Edge IP address shown in your StackPath site overview.

6. Test Response Headers and Verification

Once Namecheap points to the StackPath edge, curl a hashed asset to verify the cache pipeline:

curl -I https://example.com/_app/immutable/chunks/index.d1f94d3e.js

Check the response headers in your terminal:

HTTP/2 200
date: Mon, 14 Apr 2025 15:20:10 GMT
content-type: application/javascript
cache-control: max-age=31536000, public, immutable
x-cache: HIT
x-hw: 1681485610.d002.am2.t, 1681485610.c001.am2.h
server: StackPath

Watch the x-cache header. On your first curl, it will return MISS because StackPath had to pull the file from Hostinger. Run that exact curl command a second time and it flips to HIT. Your CDN is now serving the file directly from edge memory without touching your origin server.

7. Gotchas I Hit During This Deployment

Here are the real issues I bumped into while wiring this up:

1. Direct URL visits returning 404 on refresh
Client-side navigation worked great, but refreshing a page like example.com/docs/getting-started threw Hostinger’s generic 404 page. Without index.html sitting inside a folder named getting-started/, LiteSpeed had no idea what file to load. Per the SvelteKit static adapter documentation, setting trailingSlash = 'always' in +layout.js creates actual subdirectories for every single page, solving the issue at build time.

2. LiteSpeed Gzip vs Brotli clashes
Hostinger’s LiteSpeed web server compresses assets dynamically. If you turn on precompress: true in svelte.config.js, SvelteKit leaves pre-built .gz and .br files in your build output. When uploaded, LiteSpeed often served those files with broken mime types unless your .htaccess was loaded with custom conditions. Keep precompress: false and let Hostinger and StackPath compress on the fly.

3. Stale cache after new deployments
Because SvelteKit generates unique hashes for every file inside _app/immutable/, you never have to purge asset caches after a release. But if StackPath caches your HTML files, users will keep loading the old bundle until that cache expires. Forcing no-cache on all HTML files completely eliminates the need for manual cache purges.

Frequently Asked Questions

Can I use server endpoints (+server.js) with adapter-static?

Only GET endpoints will work. SvelteKit executes the GET handler during npm run build and saves the output as a flat JSON file. POST, PUT, or DELETE endpoints will fail the build immediately because a static web host can’t execute Node backend code.

Why use Hostinger if StackPath caches all the files anyway?

A CDN is an edge cache, not durable storage. When an edge POP drops cold assets or gets a cache miss, it has to fetch the authoritative file from somewhere. Hostinger gives you a cheap, reliable origin server to hold those base files.

Do I need StackPath’s Origin Shield?

For most personal sites and small blogs, no. But for high-traffic sites, Origin Shield routes all regional edge cache misses through one parent edge node before hitting Hostinger, keeping your origin from getting hammered during spikes.

What happens if I update a page’s content?

Run npm run build locally, sync the build/ directory to Hostinger via rsync, and you’re done. Because the updated HTML points to new hashed JS and CSS bundles, returning visitors get the changes immediately without needing to hard refresh.

Next Steps

Run your live site through WebPageTest to confirm your edge TTFB is where it should be. If you’re mixing static pages with dynamic platforms on the same domain, read our breakdown on customizing StackPath EdgeRules to keep your caching logic clean.

all_in_one_marketing_tool