{"record":{"id":"d242b65fcff1e923","repo":"sveltejs/kit","slug":"the-sveltekit-options-from-the-vite-config-must-be","errorCode":null,"errorMessage":"The SvelteKit options from the Vite config must be an object. See https://svelte.dev/docs/kit/configuration","messagePattern":"The SvelteKit options from the Vite config must be an object\\. See https://svelte\\.dev/docs/kit/configuration","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/kit/src/core/config/index.js","lineNumber":173,"sourceCode":"\t\t\tconfig.files.hooks.server = path.resolve(cwd, config.files.hooks.server);\n\t\t\tconfig.files.hooks.universal = path.resolve(cwd, config.files.hooks.universal);\n\t\t} else if (key !== 'lib' /* TODO remove when we remove the `lib` option altogether */) {\n\t\t\t// @ts-expect-error\n\t\t\tconfig.files[key] = path.resolve(cwd, config.files[key]);\n\t\t}\n\t}\n\n\treturn config;\n}\n\n/**\n * @param {Config} config\n * @returns {ValidatedConfig}\n */\nexport function validate_config(config) {\n\ttry {\n\t\tif (typeof config !== 'object') {\n\t\t\tthrow new Error(\n\t\t\t\t'The SvelteKit options from the Vite config must be an object. See https://svelte.dev/docs/kit/configuration'\n\t\t\t);\n\t\t}\n\n\t\tconst validated = validate_options(config, 'config');\n\t\tconst files = validated.files;\n\n\t\tfiles.hooks.client ??= path.join(files.src, 'hooks.client');\n\t\tfiles.hooks.server ??= path.join(files.src, 'hooks.server');\n\t\tfiles.hooks.universal ??= path.join(files.src, 'hooks');\n\t\tfiles.params ??= path.join(files.src, 'params');\n\t\tfiles.routes ??= path.join(files.src, 'routes');\n\t\tfiles.serviceWorker ??= path.join(files.src, 'service-worker');\n\t\tfiles.appTemplate ??= path.join(files.src, 'app.html');\n\t\tfiles.errorTemplate ??= path.join(files.src, 'error.html');\n\n\t\tif (validated.router.resolution === 'server') {\n\t\t\tif (validated.router.type === 'hash') {","sourceCodeStart":155,"sourceCodeEnd":191,"githubUrl":"https://github.com/sveltejs/kit/blob/03f1687fe612ce3d2d9131139b5b188d9cf90c64/packages/kit/src/core/config/index.js#L155-L191","documentation":"validate_config receives the `kit` (SvelteKit options) section exported from the Vite config. If that value is not an object (e.g. undefined, a string, or a function), validation cannot proceed, so it throws with a pointer to the configuration docs. This typically happens when svelte.config.js fails to export the config correctly or the Vite plugin receives malformed options.","triggerScenarios":"validate_config is called (via extract_svelte_config / validate_paths) with a `config` argument whose typeof is not 'object' — commonly `undefined` because svelte.config.js has no default export, or the loaded module resolved to a non-object value.","commonSituations":"Forgetting `export default config` in svelte.config.js; a typo like `export defualt`; importing the config file from a CJS/ESM mismatch so the interop yields undefined; passing the config object inside a wrapper instead of directly.","solutions":["Ensure svelte.config.js exports the object as default: `export default { kit: {...} }` (or `module.exports = {...}`).","If using ESM/CJS interop in a custom loader, read `.default` from the imported module.","Check that the Vite plugin invocation receives the kit options object, not a string or function."],"exampleFix":"// before: svelte.config.js missing export\nconst config = { kit: { adapter: adapter() } };\n// after\nconst config = { kit: { adapter: adapter() } };\nexport default config;","handlingStrategy":"type-guard","validationCode":"const mod = await import('./svelte.config.js');\nconst config = mod.default ?? mod;\nif (typeof config !== 'object' || config === null) {\n  throw new Error('svelte.config.js must default-export an object');\n}","typeGuard":"/** @returns {config is Record<string, unknown>} */\nfunction isKitConfig(value) {\n  return typeof value === 'object' && value !== null;\n}","tryCatchPattern":"try {\n  const cfg = (await import('./svelte.config.js')).default;\n} catch (e) {\n  if (e.message.includes('must be an object')) {\n    console.error('Check svelte.config.js: missing `export default config`?');\n  }\n  throw e;\n}","preventionTips":["Always `export default config` in svelte.config.js","Verify config loads with `node -e \"import('./svelte.config.js').then(m => console.log(typeof m.default))\"`","Watch for ESM/CJS interop issues — unwrap .default when needed","Run `vite dev` early after config edits to catch export mistakes"],"tags":["config","validation","type-mismatch","esm"],"backgroundTag":"invalid-config-shape","analyzedSha":"03f1687fe612ce3d2d9131139b5b188d9cf90c64","analyzedAt":"2026-09-02T02:01:50.504Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T06:17:21.866Z"}