sveltejs/kit · error · Error

SvelteKit configuration (${keys}) no longer lives inside a `

Error message

SvelteKit configuration (${keys}) no longer lives inside a `kit` namespace. Pass it directly to the `sveltekit(...)` Vite plugin

What it means

Older SvelteKit versions nested all config under a top-level `kit` object (`kit: { paths: {...} }`). Now SvelteKit options are passed directly at the top level (or directly to the `sveltekit(...)` Vite plugin), and any `kit` key is rejected, listing the nested keys found.

Source

Thrown at packages/kit/src/core/config/options.js:171

				`\`${keypath}\` has been removed. Use #lib instead of $lib: https://svelte.dev/docs/kit/$lib`
		),
		params: string(null),
		routes: string(null),
		serviceWorker: string(null),
		appTemplate: string(null),
		errorTemplate: string(null)
	}),

	inlineStyleThreshold: number(0),

	moduleExtensions: string_array(['.js', '.ts']),

	kit: validate(undefined, (input) => {
		const keys = Object.keys(input)
			.map((key) => `\`${key}\``)
			.join(', ');

		throw new Error(
			`SvelteKit configuration (${keys}) no longer lives inside a \`kit\` namespace. Pass it directly to the \`sveltekit(...)\` Vite plugin`
		);
	}),

	outDir: string('.svelte-kit'),

	output: object({
		linkHeaderPreload: boolean(false),
		preloadStrategy: removed(
			(keypath) => `\`${keypath}\` has been removed. modulepreload will always be used`
		),
		bundleStrategy: list(['split', 'single', 'inline'])
	}),

	paths: object({
		base: validate('', (input, keypath) => {
			assert_string(input, keypath);

View on GitHub (pinned to 03f1687fe6)

Solutions

  1. Hoist the nested keys to the top level: `kit: { paths: {...} }` becomes `paths: {...}`
  2. Remove the `kit` wrapper key entirely
  3. If configuring via Vite, pass options directly to the `sveltekit(...)` plugin, not nested
  4. Consult the current configuration docs and migrate each listed key (the error names them)

Example fix

// before
const config = {
  kit: { paths: { base: '/app' } }
};
// after
const config = {
  paths: { base: '/app' }
};
Defensive patterns

Strategy: validation

Validate before calling

if ('kit' in config) {
  throw new Error(`Move kit.* keys (${Object.keys(config.kit ?? {}).join(', ')}) to the top level`);
}

Type guard

function hasNoKitNamespace(config) {
  return !('kit' in config);
}

Try / catch

try {
  loadConfig();
} catch (e) {
  if (String(e.message).includes('no longer lives inside a `kit` namespace')) {
    console.error('Flatten the kit object to top-level keys per current SvelteKit docs');
  }
  throw e;
}

Prevention

When it happens

Trigger: Upgrading from an old SvelteKit version and keeping `kit: { ... }` in svelte.config.js; following outdated tutorials/docs that use the `kit` namespace; migrating a Vite config that passed kit options inside the plugin options under `kit`.

Common situations: Version migration (SvelteKit pre-1.0 → 1.x/2.x); AI or docs-generated config from old examples; merging old config files into new projects.

Related errors


AI-assisted analysis of sveltejs/kit@03f1687fe6 (2026-09-02). Data as JSON: /api/errors/8940c07762a0782f. Report an issue: GitHub.