Deploying SvelteKit to Cloudflare Pages
CloudflareSvelteKitDeployment
This portfolio is fully prerendered and served from Cloudflare’s edge. No servers to manage, no cold starts — just static assets delivered close to the visitor.
The adapter
SvelteKit’s @sveltejs/adapter-cloudflare produces the output Cloudflare Pages expects. The config
stays tiny:
import adapter from '@sveltejs/adapter-cloudflare';
const config = {
kit: { adapter: adapter() }
}; Setting export const prerender = true in the root layout makes every reachable route render to
static HTML at build time.
Continuous deployment
A small GitHub Actions workflow typechecks and builds on every pull request, then deploys pushes to main:
npm run check— typecheck withsvelte-checknpm run build— output to.svelte-kit/cloudflarewrangler pages deploy— ship to the edge
Why static-first
- Fast — assets are cached globally, time-to-first-byte is near zero
- Cheap — no compute billing for a content site
- Resilient — there is no origin to fall over
For a portfolio or a blog, this is hard to beat. The constraint of “no runtime data” turns out to be a feature: it keeps the site simple and the Lighthouse scores high.