Adapters
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 vite.config.js:
import { function sveltekit(config?: KitViteConfig): Promise<PluginOption[]>Returns the SvelteKit Vite plugins.
sveltekit } from '@sveltejs/kit/vite';
import { function defineConfig(config: UserConfig): UserConfig (+5 overloads)Type helper to make it easier to use vite.config.ts
accepts a direct
{@link
UserConfig
}
object, or a function that returns it.
The function receives a
{@link
ConfigEnv
}
object.
defineConfig } from 'vite';
import const adapter: (opts?: any) => import("@sveltejs/kit").Adapteradapter from 'svelte-adapter-foo';
export default function defineConfig(config: UserConfig): UserConfig (+5 overloads)Type helper to make it easier to use vite.config.ts
accepts a direct
{@link
UserConfig
}
object, or a function that returns it.
The function receives a
{@link
ConfigEnv
}
object.
defineConfig({
UserConfig.plugins?: PluginOption[] | undefinedArray of vite plugins to use.
plugins: [
function sveltekit(config?: KitViteConfig): Promise<PluginOption[]>Returns the SvelteKit Vite plugins.
sveltekit({
KitViteConfig.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()
})
]
});Legacy mode
The
adapteroption was moved to the SvelteKit Vite plugin in SvelteKit 3.0.0. In earlier versions, you had to add it to thekitproperty in thesvelte.config.jsfile instead.
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.
Edit this page on GitHub llms.txt