From harness-claude
Guides configuring SvelteKit adapters for Node, Vercel, Cloudflare Pages, and Netlify deployment.
How this skill is triggered — by the user, by Claude, or both
Slash command
/harness-claude:svelte-adapter-configThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
> Deploy SvelteKit to any platform by selecting and configuring the correct adapter in svelte.config.js
Deploy SvelteKit to any platform by selecting and configuring the correct adapter in svelte.config.js
Selecting an adapter:
svelte.config.js:// svelte.config.js
import adapter from '@sveltejs/adapter-auto'; // or specific adapter
export default {
kit: {
adapter: adapter(),
},
};
adapter-auto (default):
adapter-auto detects the deployment environment and selects the correct adapter automatically. It works for Vercel, Netlify, and Cloudflare Pages with zero configuration:npm install -D @sveltejs/adapter-auto
Note: For production, prefer the specific adapter to avoid ambiguity and get access to all configuration options.
adapter-node — Node.js server:
npm install -D @sveltejs/adapter-node
import adapter from '@sveltejs/adapter-node';
export default {
kit: {
adapter: adapter({
out: 'build', // output directory
precompress: true, // gzip/brotli static assets
envPrefix: 'APP_', // prefix for environment variable access
}),
},
};
Run the output: node build/index.js. Set PORT and HOST env vars to configure the server.
adapter-vercel:
npm install -D @sveltejs/adapter-vercel
import adapter from '@sveltejs/adapter-vercel';
export default {
kit: {
adapter: adapter({
runtime: 'nodejs20.x', // or 'edge'
regions: ['iad1'], // function regions
isr: { expiration: 60 }, // ISR default
}),
},
};
Configure per-route behavior using export const config in route files:
// src/routes/api/stream/+server.ts
export const config = {
runtime: 'edge',
};
adapter-cloudflare:
npm install -D @sveltejs/adapter-cloudflare
import adapter from '@sveltejs/adapter-cloudflare';
export default {
kit: {
adapter: adapter({
routes: { include: ['/*'], exclude: ['<all>'] },
}),
},
};
Access Cloudflare bindings (KV, R2, D1) via event.platform.env:
// +page.server.ts
export const load: PageServerLoad = async ({ platform }) => {
const kv = platform?.env?.MY_KV_NAMESPACE;
const value = await kv?.get('my-key');
return { value };
};
Declare the App.Platform interface for type safety:
// src/app.d.ts
declare global {
namespace App {
interface Platform {
env: {
MY_KV_NAMESPACE: KVNamespace;
MY_D1: D1Database;
};
}
}
}
adapter-static — full static export:
npm install -D @sveltejs/adapter-static
import adapter from '@sveltejs/adapter-static';
export default {
kit: {
adapter: adapter({
pages: 'build',
assets: 'build',
fallback: '200.html', // for SPA mode
precompress: false,
strict: true,
}),
},
};
All pages must be prerenderable. Disable SSR globally or per-page for SPA mode:
// src/routes/+layout.ts
export const ssr = false;
export const prerender = true;
Prerendering specific pages:
// +page.ts or +page.server.ts
export const prerender = true;
Or configure in svelte.config.js:
export default {
kit: {
prerender: {
entries: ['/', '/about', '/blog'],
crawl: true, // follow links from prerendered pages
handleMissingId: 'warn',
},
},
};
Adapter comparison:
| Adapter | Hosting | SSR | Edge | Static files |
|---|---|---|---|---|
| adapter-auto | Vercel/Netlify/CF | Yes | Partial | CDN |
| adapter-node | VPS/Docker | Yes | No | Serve manually |
| adapter-vercel | Vercel | Yes | Yes | CDN |
| adapter-cloudflare | CF Pages | Yes | Yes (Workers) | CF CDN |
| adapter-netlify | Netlify | Yes | Yes (Edge Fns) | CDN |
| adapter-static | Any | No | No | Any CDN |
Environment variables:
SvelteKit distinguishes between build-time and runtime env vars:
// Build-time (baked into bundle):
import { PUBLIC_API_URL } from '$env/static/public';
import { SECRET_KEY } from '$env/static/private';
// Runtime (read from process.env):
import { PUBLIC_API_URL } from '$env/dynamic/public';
import { SECRET_KEY } from '$env/dynamic/private';
Use $env/dynamic/* for variables that change between deployments without a rebuild.
Cloudflare vs. Node — key differences:
fs on Cloudflare Workers — use R2 or KV for storageprocess.env on Workers — use Cloudflare bindings and platform.envadapter-node + Docker:
FROM node:20-alpine
WORKDIR /app
COPY build ./build
COPY node_modules ./node_modules
COPY package.json .
EXPOSE 3000
CMD ["node", "build/index.js"]
https://kit.svelte.dev/docs/adapters
npx claudepluginhub intense-visions/harness-engineering --plugin harness-claudeGuides SvelteKit deployment using adapters (static, Node, Cloudflare), Vite/pnpm configs, library authoring, PWA setup, and production builds.
Configures Astro adapters, environment variables, and build output for deploying to Vercel, Node.js, Cloudflare, and Netlify. Use when setting up or switching deployment targets.
Guides deployment of web frameworks (Vite/React, Astro, TanStack Start, Next.js, Nuxt, SvelteKit, Remix) on Netlify, covering adapters, environment variables, and client-side routing.