SvelteKit Adapter Configuration

VerifiedSafe

Guide to select and configure the correct adapter for deploying SvelteKit on various platforms (Node, Vercel, Cloudflare, etc.).

Sby Skills Guide Bot
DevOpsIntermediate
7/25/2026
Claude CodeCursorWindsurfCopilotCodex
#sveltekit#deployment#adapters#ssr#prerendering

Recommended for

Automated summary

This skill guides selecting and configuring the right SvelteKit adapter in svelte.config.js for a given deployment platform.

Strengths

  • Covers the main adapters (auto, node, vercel, cloudflare, static) with ready-to-use configuration snippets
  • Explains per-page SSR and prerender settings
  • Details access to Cloudflare bindings (KV, R2, D1) through event.platform plus App.Platform typing
  • Flags runtime limits per target, such as missing Node.js APIs on edge

Limitations

  • The supplied document cuts off mid-section on prerendering, leaving that part incomplete
  • Does not address less common adapters or cross-platform migrations
  • Assumes prior familiarity with SvelteKit and build configuration
When to use it

Use it when preparing a SvelteKit app for production and you need to pick or tune a deployment adapter.

When not to use it

Avoid it when you need help with Svelte UI development or with application debugging unrelated to deployment.

Security analysis

Safe
Quality score85/100

The skill is documentation-only and contains standard SvelteKit adapter setup instructions, npm install commands, configuration snippets, and a simple Dockerfile. It does not instruct destructive, exfiltrating, obfuscated, or safety-disabling actions.

No concerns found

How this analysis is made

Examples

Docker deployment
I want to deploy my SvelteKit app with Docker on a VPS. Configure adapter-node in svelte.config.js with precompression and tell me how to run the build output.
Cloudflare KV binding
Switch my SvelteKit app to Cloudflare Pages and show me how to read a value from a KV namespace in a +page.server.ts load function, including the App.Platform types.
Static export
Turn my SvelteKit site into a fully static export hosted on a plain file server, using adapter-static with a 200.html fallback.

Svelte Adapter Config

Deploy SvelteKit to any platform by selecting and configuring the correct adapter in svelte.config.js

When to Use

  • You are preparing a SvelteKit app for production deployment
  • You need to choose between Node server, Vercel, Cloudflare Pages, Netlify, or static hosting
  • You need to configure prerendering or SSR for specific routes
  • You are hitting adapter-specific runtime limitations (no Node.js APIs on edge, etc.)

Instructions

Selecting an adapter:

  1. Install and configure the appropriate adapter in svelte.config.js:
// svelte.config.js
import adapter from '@sveltejs/adapter-auto'; // or specific adapter

export default {
  kit: {
    adapter: adapter(),
  },
};

adapter-auto (default):

  1. 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:

  1. For Docker, Railway, Render, or any VPS:
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:

  1. Deploys SSR routes as Vercel serverless functions and API routes as edge functions:
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:

  1. Deploys to Cloudflare Pages + Workers:
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:

  1. Pre-renders all pages at build time for hosting on any static file server:
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:

  1. Mark pages for prerendering individually without switching the whole app to static:
// +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',
    },
  },
};

Details

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:

  • No fs on Cloudflare Workers — use R2 or KV for storage
  • Limited CPU time per request on edge — avoid heavy computation
  • No process.env on Workers — use Cloudflare bindings and platform.env
  • Bundle size limit of 1MB (compressed) on Workers

adapter-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"]

Source

https://kit.svelte.dev/docs/adapters

Process

  1. Read the instructions and examples in this document.
  2. Apply the patterns to your implementation, adapting to your specific context.
  3. Verify your implementation against the details and edge cases listed above.

Harness Integration

  • Type: knowledge — this skill is a reference document, not a procedural workflow.
  • No tools or state — consumed as context by other skills and agents.

Success Criteria

  • The patterns described in this document are applied correctly in the implementation.
  • Edge cases and anti-patterns listed in this document are avoided.

From the file to a first result

The download contains exactly the content displayed on this page. This copy may differ from the latest version in the source repository.

View the source and supporting files

This download contains SKILL.md only. Any scripts, references, templates and dependencies are not included. Get the required files from the source, preserving their directory structure, before continuing.

1. Download the file

Download SKILL.md

From the root of a test project, save the file as .skill-downloads/sveltekit-adapter-configuration-mrzxuqvd/SKILL.md, or use the command below. This folder is for inspecting the skill before installation.

Command for macOS/Linux or WSL: requires a POSIX shell and curl. On Windows without WSL, use the download button and create the folder manually.

mkdir -p '.skill-downloads/sveltekit-adapter-configuration-mrzxuqvd' && curl --fail --show-error --location 'https://skills-guides.com/api/skills/sveltekit-adapter-configuration-mrzxuqvd/download' --output '.skill-downloads/sveltekit-adapter-configuration-mrzxuqvd/SKILL.md.part' && mv '.skill-downloads/sveltekit-adapter-configuration-mrzxuqvd/SKILL.md.part' '.skill-downloads/sveltekit-adapter-configuration-mrzxuqvd/SKILL.md'

2. Check prerequisites

Read SKILL.md before using it. If it references scripts or external services, inspect them and prepare the required access in your test environment.

No recognized prerequisites section in this file. This does not mean it is self-contained: libraries, tools and access requirements may be mentioned elsewhere in the content or source repository.

The platforms on this page are catalog indications. The paths below follow tool documentation; they do not prove this skill has been run in those tools. No minimum tool version is confirmed for this listing.

3. Load the skill

This file does not provide a usable name/description header for this native procedure. It remains available to download and inspect; use the manual method below.

Manual method or another tool: attach SKILL.md to a conversation, or open it in an agent that can read files. Include any required supporting resources. No universal folder is recognized by every tool.

4. Try a first task

Use a short, synthetic input: an API endpoint, a small document or an interface brief. In a new conversation, attach the file or give the agent its path, then adapt this request:

Read .skill-downloads/sveltekit-adapter-configuration-mrzxuqvd/SKILL.md and apply its instructions to this example: [describe a test input]. Identify any missing files, dependencies or access. Produce the result requested by the skill without inventing data or running unreviewed scripts.

Expected result: output matching the skill instructions, or a precise list of missing prerequisites. A read confirmation alone does not validate a first use. If an external resource is unavailable, that path remains untested.

Related skills