SvelteKit • Build and deploy
Adapters
On this page
Before you can deploy your SvelteKit app, you need to adapt it for your deployment target. Adapters are small plugins that take the built app as input and generate output for deployment.
Official adapters exist for a variety of platforms — these are documented on the following pages:
@sveltejs/adapter-cloudflarefor Cloudflare Workers and Cloudflare Pages@sveltejs/adapter-netlifyfor Netlify@sveltejs/adapter-nodefor Node servers@sveltejs/adapter-staticfor static site generation (SSG)@sveltejs/adapter-vercelfor Vercel
Additional community-provided adapters exist for other platforms.
Using adapters
Your adapter is specified in svelte.config.js:
// @filename: ambient.d.ts
declare module 'svelte-adapter-foo' {
const const adapter: (opts: any) => import("@sveltejs/kit").Adapterconst adapter: (opts: any) => import("@sveltejs/kit").Adapteradapter: (opts: anyopts: anyopts: any) => import('@sveltejs/kit').Adapter;
export default const adapter: (opts: any) => import("@sveltejs/kit").Adapterconst adapter: (opts: any) => import("@sveltejs/kit").Adapteradapter;
}
// @filename: index.ts
// cut
import const adapter: (opts: any) => import("@sveltejs/kit").Adapteradapter from 'svelte-adapter-foo';
import type { Config } from '@sveltejs/kit';
const const config: Configconfig: Config = {
Config.kit?: KitConfig | undefinedSvelteKit options.
kit: {
KitConfig.adapter?: Adapter | undefinedYour adapter is run when executing vite build. It determines how the output is converted for different platforms.
adapter: function adapter(opts: any): import("@sveltejs/kit").Adapteradapter({
// adapter options go here
})
}
};
export default const config: Configconfig;// @filename: ambient.d.ts
declare module 'svelte-adapter-foo' {
const const adapter: (opts: any) => import("@sveltejs/kit").Adapterconst adapter: (opts: any) => import("@sveltejs/kit").Adapteradapter: (opts: anyopts: anyopts: any) => import('@sveltejs/kit').Adapter;
export default const adapter: (opts: any) => import("@sveltejs/kit").Adapterconst adapter: (opts: any) => import("@sveltejs/kit").Adapteradapter;
}
// @filename: index.js
// cut
import const adapter: (opts: any) => import("@sveltejs/kit").Adapteradapter from 'svelte-adapter-foo';
/** @type {import('@sveltejs/kit').Config} */
const const config: Configconfig = {
Config.kit?: KitConfig | undefinedSvelteKit options.
kit: {
KitConfig.adapter?: Adapter | undefinedYour adapter is run when executing vite build. It determines how the output is converted for different platforms.
adapter: function adapter(opts: any): import("@sveltejs/kit").Adapteradapter({
// adapter options go here
})
}
};
export default const config: Configconfig;Platform-specific context
Some adapters may have access to additional information about the request. For example, Cloudflare Workers can access an env object containing KV namespaces etc. This can be passed to the RequestEvent used in hooks and server routes as the platform property — consult each adapter’s documentation to learn more.