withastro/astro · warning
Astro.generator inside getStaticPaths is deprecated and will
Error message
Astro.generator inside getStaticPaths is deprecated and will be removed in a future major version of Astro.
What it means
Astro.generator read inside getStaticPaths comes from the same mocked global created by createAstro(): it still returns the generator string (e.g. astro/v5.x.y) but the getter logs a deprecation warning, and the source is marked to throw in Astro 7. Unlike `site` there is no import.meta.env equivalent — the version is exported directly by the astro package as ASTRO_VERSION, which is the intended replacement.
Source
Thrown at packages/astro/src/runtime/server/astro-global.ts:27
});
}
// This is used to create the top-level Astro global; the one that you can use
// inside of getStaticPaths. See the `astroGlobalArgs` option for parameter type.
export function createAstro(site: string | undefined): AstroGlobal {
return {
// TODO: throw in Astro 8
get site() {
// This is created inside of the runtime so we don't have access to the Astro logger.
console.warn(
`Astro.site inside getStaticPaths is deprecated and will be removed in a future major version of Astro. Use import.meta.env.SITE instead`,
);
return site ? new URL(site) : undefined;
},
// TODO: throw in Astro 8
get generator() {
// This is created inside of the runtime so we don't have access to the Astro logger.
console.warn(
`Astro.generator inside getStaticPaths is deprecated and will be removed in a future major version of Astro.`,
);
return ASTRO_GENERATOR;
},
get callAction(): any {
throw createError('callAction');
},
get clientAddress(): any {
throw createError('clientAddress');
},
get cookies(): any {
throw createError('cookies');
},
get csp(): any {
throw createError('csp');
},
get currentLocale(): any {
throw createError('currentLocale');View on GitHub (pinned to 3578d45d34)
Solutions
- Import { ASTRO_VERSION } from 'astro' and build the string `astro/${ASTRO_VERSION}` yourself
- Move generator/version logic out of getStaticPaths into the rendered page, frontmatter render fn, or an integration
- For version-dependent behavior, compare ASTRO_VERSION or use feature detection instead of Astro.generator
Example fix
// before
export async function getStaticPaths() {
const generator = Astro.generator; // deprecation warning
...
}
// after
import { ASTRO_VERSION } from 'astro';
export async function getStaticPaths() {
const generator = `astro/${ASTRO_VERSION}`;
...
} Defensive patterns
Strategy: validation
Validate before calling
import { ASTRO_VERSION } from 'astro';
// single source of truth usable from getStaticPaths and components alike
export const generator = `astro/${ASTRO_VERSION}`; Prevention
- Never read the mocked Astro global inside getStaticPaths; import ASTRO_VERSION instead
- Keep a shared constants module for generator/version strings
- Watch Astro upgrade guides for properties scheduled to throw (the source marks these TODO throw in Astro 7)
When it happens
Trigger: Reading `Astro.generator` inside an exported getStaticPaths() function — e.g. emitting a <meta name="generator"> tag or RSS/JSON-feed generator field from static path generation — during dev or build.
Common situations: Feed generation inside getStaticPaths that stamps the producing framework; version-gated static route generation; appears after upgrading to the Astro version that deprecated the mocked global's properties.
Understand the failure class
Background: "is deprecated and will be removed" — deprecation warnings for old API names, keywords, and options, and how to migrate before the removal release — this error's family across 29 libraries.
Related errors
- Astro.site inside getStaticPaths is deprecated and will be r
- GetStaticPathsRequired
- InvalidGetStaticPathsReturn
- InvalidGetStaticPathsEntry
- GetStaticPathsExpectedParams
AI-assisted analysis of withastro/astro@3578d45d34 (2026-08-21).
Data as JSON: /api/errors/91aa43a4edf4b287.
Report an issue: GitHub.