SvelteKit • Reference

Configuration

On this page

Your project’s configuration lives in a svelte.config.js file at the root of your project. As well as SvelteKit, this config object is used by other tooling that integrates with Svelte such as editor extensions.

// @filename: ambient.d.ts
declare module '@sveltejs/adapter-auto' {
	const const plugin: () => import("@sveltejs/kit").Adapterconst plugin: () => import("@sveltejs/kit").Adapterplugin: () => import('@sveltejs/kit').Adapter;
	export default const plugin: () => import("@sveltejs/kit").Adapterconst plugin: () => import("@sveltejs/kit").Adapterplugin;
}

// @filename: index.ts
// cut
import const adapter: () => import("@sveltejs/kit").Adapteradapter from '@sveltejs/adapter-auto';
import type { Config } from '@sveltejs/kit';

const const config: Configconfig: Config = {
	Config.kit?: KitConfig | undefined

SvelteKit options.

@seehttps://svelte.dev/docs/kit/configuration
kit
: {
KitConfig.adapter?: Adapter | undefined

Your adapter is run when executing vite build. It determines how the output is converted for different platforms.

@defaultundefined
adapter
: function adapter(): import("@sveltejs/kit").Adapteradapter()
} }; export default const config: Configconfig;
// @filename: ambient.d.ts
declare module '@sveltejs/adapter-auto' {
	const const plugin: () => import("@sveltejs/kit").Adapterconst plugin: () => import("@sveltejs/kit").Adapterplugin: () => import('@sveltejs/kit').Adapter;
	export default const plugin: () => import("@sveltejs/kit").Adapterconst plugin: () => import("@sveltejs/kit").Adapterplugin;
}

// @filename: index.js
// cut
import const adapter: () => import("@sveltejs/kit").Adapteradapter from '@sveltejs/adapter-auto';

/** @type {import('@sveltejs/kit').Config} */
const const config: Config
@type{import('@sveltejs/kit').Config}
config
= {
Config.kit?: KitConfig | undefined

SvelteKit options.

@seehttps://svelte.dev/docs/kit/configuration
kit
: {
KitConfig.adapter?: Adapter | undefined

Your adapter is run when executing vite build. It determines how the output is converted for different platforms.

@defaultundefined
adapter
: function adapter(): import("@sveltejs/kit").Adapteradapter()
} }; export default const config: Config
@type{import('@sveltejs/kit').Config}
config
;

Since version 2.62.0 you can also pass your configuration to the sveltekit plugin in your Vite config, along with the Svelte compiler options:

// @filename: ambient.d.ts
declare module '@sveltejs/adapter-auto' {
	const const plugin: () => import("@sveltejs/kit").Adapterconst plugin: () => import("@sveltejs/kit").Adapterplugin: () => import('@sveltejs/kit').Adapter;
	export default const plugin: () => import("@sveltejs/kit").Adapterconst plugin: () => import("@sveltejs/kit").Adapterplugin;
}

// @filename: index.js
// cut
import const adapter: () => import("@sveltejs/kit").Adapteradapter from '@sveltejs/adapter-auto';
import { function sveltekit(config?: KitConfig & Omit<Options, "onwarn"> & Pick<SvelteConfig, "vitePlugin">): Promise<Plugin[]>

Returns the SvelteKit Vite plugins. Since version 2.62.0 you can pass configuration directly, in which case svelte.config.js is ignored. Any options that don't belong to SvelteKit are passed through to vite-plugin-svelte.

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';
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[] | undefined

Array of vite plugins to use.

plugins
: [
function sveltekit(config?: KitConfig & Omit<Options, "onwarn"> & Pick<SvelteConfig, "vitePlugin">): Promise<Plugin[]>

Returns the SvelteKit Vite plugins. Since version 2.62.0 you can pass configuration directly, in which case svelte.config.js is ignored. Any options that don't belong to SvelteKit are passed through to vite-plugin-svelte.

sveltekit
({
compilerOptions?: Omit<CompileOptions, "filename" | "format" | "generate"> | undefined

The options to be passed to the Svelte compiler. A few options are set by default, including dev and css. However, some options are non-configurable, like filename, format, generate, and cssHash (in dev).

@seehttps://svelte.dev/docs/svelte/svelte-compiler#CompileOptions
compilerOptions
: {
experimental?: {
    async?: boolean;
} | undefined

Experimental options

@since5.36
experimental
: {
async?: boolean | undefined

Allow await keyword in deriveds, template expressions, and the top level of components

@since5.36
async
: true
} }, KitConfig.adapter?: Adapter | undefined

Your adapter is run when executing vite build. It determines how the output is converted for different platforms.

@defaultundefined
adapter
: function adapter(): import("@sveltejs/kit").Adapteradapter(),
KitConfig.experimental?: ({
    explicitEnvironmentVariables?: boolean;
    tracing?: {
        server?: boolean;
    };
    instrumentation?: {
        server?: boolean;
    };
    remoteFunctions?: boolean;
    forkPreloads?: boolean;
    handleRenderingErrors?: boolean;
} & ExperimentalOptions) | undefined

Experimental features. Here be dragons. These are not subject to semantic versioning, so breaking changes or removal can happen in any release.

These options are considered experimental and breaking changes to them can occur in any release

experimental
: {
remoteFunctions?: boolean | undefined

Whether to enable the experimental remote functions feature. This feature is not yet stable and may be changed or removed at any time.

@defaultfalse
remoteFunctions
: true
} }) ] });

The kit namespace is at the same level as the other top level entries; this is the only difference to the svelte.config.js layout.

Any options that don’t belong to SvelteKit are passed through to vite-plugin-svelte, so you can set options like inspector here too. The experimental namespace is shared — SvelteKit reads its own flags and forwards the rest.

If the config is defined via the plugin, the svelte.config.js file is ignored.

Config

Config

An extension of vite-plugin-svelte's options.

export interface Config extends SvelteConfig {/*…*/}
kit?: KitConfig;

SvelteKit options.

[key: string]: any;

Any additional options required by tooling that integrates with Svelte.

KitConfig

The kit property configures SvelteKit, and can have the following properties:

EXPANDED_TYPES: Configuration#KitConfig