withastro/astro · error · AstroError
LiveContentConfigError
LiveContentConfigError
Error message
Collections with type `live` must be defined in a `src/live.config.ts` file. Check your collection definitions in your live content config file.
What it means
Thrown by the runtime-shimmed defineCollection() (re-exported into src/content/config.ts) when called with { type: 'live' }. Live collections are not permitted in the standard content config; they must be declared in a dedicated src/live.config.ts. This shim exists to catch users who copy a live-collection example into the wrong file.
Source
Thrown at packages/astro/src/content/runtime.ts:748
});
};
}
type PropagatedAssetsModule = {
__astroPropagation: true;
getMod: () => Promise<any>;
collectedStyles: string[];
collectedLinks: string[];
collectedScripts: string[];
};
function isPropagatedAssetsModule(module: any): module is PropagatedAssetsModule {
return typeof module === 'object' && module != null && '__astroPropagation' in module;
}
export function defineCollection(config: any) {
if (config.type === 'live') {
throw new AstroError({
...AstroErrorData.LiveContentConfigError,
message: AstroErrorData.LiveContentConfigError.message(
'Collections with type `live` must be defined in a `src/live.config.ts` file.',
),
});
}
return defineCollectionOrig(config);
}
export function defineLiveCollection() {
throw new AstroError({
...AstroErrorData.LiveContentConfigError,
message: AstroErrorData.LiveContentConfigError.message(
'Live collections must be defined in a `src/live.config.ts` file.',
),
});
}
View on GitHub (pinned to d081033d5f)
Solutions
- Create src/live.config.ts and define live collections there using the live-specific API.
- Remove the { type: 'live' } collection from src/content/config.ts.
- Consult the live collections guide to confirm the correct file and loader API.
Example fix
// before - src/content/config.ts
import { defineCollection } from 'astro:content';
export const collections = {
news: defineCollection({ type: 'live', loader: newsLoader() })
};
// after - src/live.config.ts
import { defineLiveCollection } from 'astro:content';
export const collections = {
news: defineLiveCollection({ loader: newsLoader() })
}; Defensive patterns
Strategy: validation
Validate before calling
// Enforce file-location convention in your config lint
import { readFileSync } from 'node:fs';
const cfg = readFileSync('src/content/config.ts','utf-8');
if (/type:\s*['"]live['"]/.test(cfg)) throw new Error('live collections belong in src/live.config.ts'); Type guard
type LiveDef = { type: 'live'; loader: unknown }; const isLiveDef = (c: any): c is LiveDef => c?.type === 'live'; Prevention
- Keep live collections exclusively in src/live.config.ts.
- Use defineLiveCollection (not defineCollection with type:'live') for live collections.
- Document the two-config-file split for new contributors.
When it happens
Trigger: In src/content/config.ts (or any module other than src/live.config.ts), calling defineCollection({ type: 'live', loader: ... }) triggers the guard immediately at config-eval time.
Common situations: Following a live-collections tutorial but pasting the definition into content/config.ts; upgrading Astro and trying the new live feature in the wrong file; misreading the docs about where live collections live.
Related errors
- LiveContentConfigError
- LiveContentConfigError
- A content collection is defined with legacy features (e.g. m
- Live content collections must be defined in "src/live.config
- FileGlobNotSupported
AI-assisted analysis of withastro/astro@d081033d5f (2026-08-12).
Data as JSON: /api/errors/46c39a4ca5e1692c.
Report an issue: GitHub.