sveltejs/kit · error

Files prefixed with + are reserved (saw ${project_relative})

Error message

Files prefixed with + are reserved (saw ${project_relative})

What it means

SvelteKit reserves all files whose names begin with `+` inside src/routes for routing components (+page.svelte, +layout.svelte, +error.svelte). During `svelte-kit sync`, the analyzer tries to parse a `+`-prefixed filename with component_name_pattern (i.e. it must end in .svelte and be exactly +page, +layout@name, or +error); if it does not match, sync aborts. This keeps the route tree unambiguous and prevents typo'd reserved files from being silently ignored.

Source

Thrown at packages/kit/src/core/sync/create_manifest_data/index.js:539

		routes: sort_routes(routes)
	};
}

/**
 * Determine if and how the file is relevant to the routing system.
 * @param {string} project_relative
 * @param {string} file
 * @param {string[]} component_extensions
 * @param {string[]} module_extensions
 * @returns {import('./types.js').RouteFile}
 */
function analyze(project_relative, file, component_extensions, module_extensions) {
	const component_extension = component_extensions.find((ext) => file.endsWith(ext));
	if (component_extension) {
		const name = file.slice(0, -component_extension.length);
		const match = component_name_pattern.exec(name);
		if (!match) {
			throw new Error(`Files prefixed with + are reserved (saw ${project_relative})`);
		}

		return {
			kind: 'component',
			is_page: !!match[1],
			is_layout: !!match[3],
			is_error: !!match[5],
			uses_layout: match[2] ?? match[4]
		};
	}

	const module_extension = module_extensions.find((ext) => file.endsWith(ext));
	if (module_extension) {
		const name = file.slice(0, -module_extension.length);
		const match = module_name_pattern.exec(name);
		if (!match) {
			throw new Error(`Files prefixed with + are reserved (saw ${project_relative})`);
		} else if (match[3] || match[6]) {

View on GitHub (pinned to 03f1687fe6)

Solutions

  1. Rename the offending file to an exact reserved name: +page.svelte, +layout.svelte, +error.svelte, or +layout@group.svelte.
  2. If it is not a route component, move it out of src/routes (or drop the `+` prefix from its name).
  3. If it is a shared component, rename to e.g. Widget.svelte and place it outside src/routes or in a subfolder not matched as a route file.

Example fix

// before
src/routes/+Page.svelte
// after
src/routes/+page.svelte
Defensive patterns

Strategy: validation

Validate before calling

const PATTERN = /^\+(?:(page(?:@.*)?)|(layout(?:@.*)?)|(error))$/;
for (const f of routeFiles.filter((f) => f.startsWith('+') && f.endsWith('.svelte'))) {
  if (!PATTERN.test(f.slice(0, -'.svelte'.length))) throw new Error(`Invalid reserved Svelte file: ${f}`);
}

Type guard

function isValidRouteComponent(basename) {
  return /^\+(?:(page(?:@.*)?)|(layout(?:@.*)?)|(error))$/.test(basename);
}

Try / catch

null

Prevention

When it happens

Trigger: A file under src/routes has a `+` prefix and a .svelte extension but is not one of +page.svelte, +layout.svelte, +layout@group.svelte, +error.svelte — e.g. +Page.svelte (capital P), +pages.svelte, or +foo.svelte — and is passed to analyze() during create_manifest_data.

Common situations: Typos like +Page.svelte or +pagee.svelte in the routes directory; copy-pasting old files into routes without renaming; scaffolding tools creating +lib.svelte-like files; mixing cases on case-insensitive filesystems.

Related errors


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