sveltejs/kit · error · Error

The SvelteKit Vite plugin ${keypath} should be an object wit

Error message

The SvelteKit Vite plugin ${keypath} should be an object with an `adapt` method. See https://svelte.dev/docs/kit/adapters

What it means

The validator for the `sveltekit(...)` plugin's `adapter` option requires an object exposing an `adapt` method (an adapter instance produced by e.g. `adapter()`). Passing anything else — a module namespace instead of a called factory, a string, or an object without `adapt` — throws this error with docs link.

Source

Thrown at packages/kit/src/exports/vite/options.js:10

/** @import { Validator } from '../../core/config/types.js' */

import { object, validate } from '../../core/config/options.js';

/** @type {Validator} */
const options = object({
	adapter: validate(undefined, (input, keypath) => {
		if (typeof input !== 'object' || !input.adapt) {
			const message = `The SvelteKit Vite plugin ${keypath} should be an object with an \`adapt\` method`;
			throw new Error(`${message}. See https://svelte.dev/docs/kit/adapters`);
		}

		return input;
	})
});

export default options;

View on GitHub (pinned to 03f1687fe6)

Solutions

  1. Call the adapter factory: `adapter: adapter()`
  2. Ensure the import is the default factory function of the adapter package
  3. If using a custom adapter, implement/expose an `adapt` method on the object
  4. Verify the adapter package version is compatible with your SvelteKit version

Example fix

// before
sveltekit({ adapter: adapterNode });
// after
sveltekit({ adapter: adapterNode() });
Defensive patterns

Strategy: type-guard

Validate before calling

const adapterInstance = adapterNode?.();
if (typeof adapterInstance !== 'object' || typeof adapterInstance?.adapt !== 'function') {
  throw new TypeError('adapter must be the result of calling an adapter factory');
}

Type guard

function isAdapter(x) {
  return typeof x === 'object' && x !== null && typeof x.adapt === 'function';
}

Try / catch

try {
  const config = validatePluginOptions({ adapter });
} catch (err) {
  if (/should be an object with an `adapt` method/.test(err.message)) {
    console.error('Did you forget to call the adapter factory, e.g. adapter()?');
  }
  throw err;
}

Prevention

When it happens

Trigger: Passing the adapter module instead of its factory result: `sveltekit({ adapter: adapterNode })` instead of `adapterNode()`; passing a custom object lacking `adapt`; passing a string name.

Common situations: Copying `import adapter from 'adapter-node'` and forgetting the `()` call; writing a custom adapter that exports the wrong shape; typo'd import that resolves to types or config instead of the factory.

Related errors


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