withastro/astro · error · AstroError

LiveContentConfigError

LiveContentConfigError

Error message

Live collections must be defined in a `src/live.config.ts` file. Check your collection definitions in ${filename}.

What it means

Thrown when the content config (`src/content.config.*`) fails Zod validation AND at least one collection in that file has `type: 'live'`. Live collections must be defined in `src/live.config.ts`, not in the regular content config. The error fires only as a secondary, more helpful message on top of the config parse failure — the code first prints the parse errors to stderr, then checks if live collections are the likely culprit.

Source

Thrown at packages/astro/src/content/utils.ts:528

	const config = contentConfigParser.safeParse(unparsedConfig);
	if (config.success) {
		// Generate a digest of the config file so we can invalidate the cache if it changes
		const hasher = await xxhash();
		const digest = hasher.h64ToString(await fs.promises.readFile(configPathname, 'utf-8'));
		return { ...config.data, digest };
	} else {
		const message = config.error.issues
			.map((issue) => `  → ${colors.green(issue.path.join('.'))}: ${colors.red(issue.message)}`)
			.join('\n');
		console.error(
			`${colors.green('[content]')} There was a problem with your content config:\n\n${message}\n`,
		);
		const liveCollections = Object.entries(unparsedConfig.collections ?? {}).filter(
			([, collection]: [string, any]) => collection?.type === LIVE_CONTENT_TYPE,
		);
		if (liveCollections.length > 0) {
			throw new AstroError({
				...AstroErrorData.LiveContentConfigError,
				message: AstroErrorData.LiveContentConfigError.message(
					'Live collections must be defined in a `src/live.config.ts` file.',
					path.relative(fileURLToPath(settings.config.root), configPathname),
				),
			});
		}
		return undefined;
	}
}

async function autogenerateCollections({
	config,
	settings,
	fs,
}: {
	config?: ContentConfig;
	settings: AstroSettings;

View on GitHub (pinned to d081033d5f)

Solutions

  1. Create `src/live.config.ts` and move all live collection definitions there.
  2. Remove `type: 'live'` collections from `src/content.config.ts` entirely.
  3. Keep regular (non-live) collections in `src/content.config.ts`.
  4. Re-run `astro dev` or `astro build` to confirm the error is gone.

Example fix

// before — src/content.config.ts
import { defineCollection } from 'astro:content';
const blog = defineCollection({ type: 'live', loader: myLoader });
export const collections = { blog };

// after — src/live.config.ts
import { defineLiveCollection } from 'astro:content';
const blog = defineLiveCollection({ loader: myLoader });
export const collections = { blog };
Defensive patterns

Strategy: validation

Validate before calling

// Check your content config before build
import { readFileSync } from 'fs';
const config = readFileSync('src/content.config.ts', 'utf-8');
if (config.includes("type: 'live'") || config.includes('type: "live"')) {
  console.error('Live collections must be in src/live.config.ts');
}

Prevention

When it happens

Trigger: A developer defines a collection with `type: 'live'` inside `src/content.config.ts` (or `.js`/`.mjs`). The content config parser rejects the config, the code detects live collections among the unparsed definitions, and throws this error pointing to the offending file.

Common situations: Following a tutorial that shows live collections without clarifying the file split. Upgrading Astro and trying the new live collections feature in the existing config file. Copying a live collection example into `content.config.ts` instead of `live.config.ts`.

Related errors


AI-assisted analysis of withastro/astro@d081033d5f (2026-08-12). Data as JSON: /api/errors/349b322ff09ed3e4. Report an issue: GitHub.