sveltejs/kit · error · Error

${params_path} does not export `params` from `defineParams`

Error message

${params_path} does not export `params` from `defineParams`

What it means

After loading the params module, SvelteKit validates that it exports a `params` object (produced by `defineParams`). This error is thrown when the module exists at `params_path` but does not export a `params` property that is an object, meaning the file was found but its shape is wrong.

Source

Thrown at packages/kit/src/utils/params.js:57

 *   root: string;
 *   load?: (file: string) => Promise<Record<string, unknown>>;
 * }} opts
 * @returns {Promise<Record<string, ParamMatcher> | null>}
 */
export async function load_and_validate_params({ routes, params_path, root, load }) {
	const names = collect_matcher_names(routes);

	if (names.size === 0) return null;

	if (!params_path) {
		throw new Error(`No matcher found for parameter '${names.values().next().value}'`);
	}

	const file = path.resolve(root, params_path);
	const module = load ? await load(file) : await import(pathToFileURL(file).href);

	if (!module.params || typeof module.params !== 'object') {
		throw new Error(`${params_path} does not export \`params\` from \`defineParams\``);
	}

	validate_param_matchers(
		/** @type {Record<string, unknown>} */ (module.params),
		names,
		params_path
	);

	return /** @type {Record<string, ParamMatcher>} */ (module.params);
}

View on GitHub (pinned to 03f1687fe6)

Solutions

  1. Export the matchers as `export const params = defineParams({...})` in the params file
  2. Ensure `defineParams` is actually called (not just referenced) and returns the object
  3. Verify `params_path` points at the correct file relative to the project root

Example fix

// before
export default defineParams({ integer: v.integer() });
// after
export const params = defineParams({ integer: v.integer() });
Defensive patterns

Strategy: type-guard

Validate before calling

const mod = await import(paramsFile);
if (!mod.params || typeof mod.params !== 'object') {
	throw new Error(`${paramsFile} must export const params = defineParams({...})`);
}

Type guard

function exportsParams(mod) {
	return mod !== null && typeof mod === 'object' && 'params' in mod && typeof mod.params === 'object' && mod.params !== null;
}

Prevention

When it happens

Trigger: The module loaded from `params_path` (via `import` or the provided `load` function) either has no `params` export, exports `params` as null/false, or exports it as a non-object (e.g. a function or array from incorrect `defineParams` usage).

Common situations: Writing `export default defineParams({...})` instead of `export const params = defineParams({...})`; forgetting to call `defineParams` and exporting the raw object; pointing `params_path` at a random file that has nothing to do with params; stale build output or wrong root directory causing the wrong module to be imported.

Related errors


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