{"record":{"id":"91aa43a4edf4b287","repo":"withastro/astro","slug":"astro-generator-inside-getstaticpaths-is-deprecate","errorCode":null,"errorMessage":"Astro.generator inside getStaticPaths is deprecated and will be removed in a future major version of Astro.","messagePattern":"Astro\\.generator inside getStaticPaths is deprecated and will be removed in a future major version of Astro\\.","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"packages/astro/src/runtime/server/astro-global.ts","lineNumber":27,"sourceCode":"\t});\n}\n\n// This is used to create the top-level Astro global; the one that you can use\n// inside of getStaticPaths. See the `astroGlobalArgs` option for parameter type.\nexport function createAstro(site: string | undefined): AstroGlobal {\n\treturn {\n\t\t// TODO: throw in Astro 8\n\t\tget site() {\n\t\t\t// This is created inside of the runtime so we don't have access to the Astro logger.\n\t\t\tconsole.warn(\n\t\t\t\t`Astro.site inside getStaticPaths is deprecated and will be removed in a future major version of Astro. Use import.meta.env.SITE instead`,\n\t\t\t);\n\t\t\treturn site ? new URL(site) : undefined;\n\t\t},\n\t\t// TODO: throw in Astro 8\n\t\tget generator() {\n\t\t\t// This is created inside of the runtime so we don't have access to the Astro logger.\n\t\t\tconsole.warn(\n\t\t\t\t`Astro.generator inside getStaticPaths is deprecated and will be removed in a future major version of Astro.`,\n\t\t\t);\n\t\t\treturn ASTRO_GENERATOR;\n\t\t},\n\t\tget callAction(): any {\n\t\t\tthrow createError('callAction');\n\t\t},\n\t\tget clientAddress(): any {\n\t\t\tthrow createError('clientAddress');\n\t\t},\n\t\tget cookies(): any {\n\t\t\tthrow createError('cookies');\n\t\t},\n\t\tget csp(): any {\n\t\t\tthrow createError('csp');\n\t\t},\n\t\tget currentLocale(): any {\n\t\t\tthrow createError('currentLocale');","sourceCodeStart":9,"sourceCodeEnd":45,"githubUrl":"https://github.com/withastro/astro/blob/3578d45d34226d63cff3d261c971c221de6794d2/packages/astro/src/runtime/server/astro-global.ts#L9-L45","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"// before\nexport async function getStaticPaths() {\n  const generator = Astro.generator; // deprecation warning\n  ...\n}\n\n// after\nimport { ASTRO_VERSION } from 'astro';\nexport async function getStaticPaths() {\n  const generator = `astro/${ASTRO_VERSION}`;\n  ...\n}","handlingStrategy":"validation","validationCode":"import { ASTRO_VERSION } from 'astro';\n// single source of truth usable from getStaticPaths and components alike\nexport const generator = `astro/${ASTRO_VERSION}`;","typeGuard":null,"tryCatchPattern":null,"preventionTips":["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)"],"tags":["astro","getstaticpaths","deprecation","astro-generator","version"],"backgroundTag":"deprecated-api-usage","analyzedSha":"3578d45d34226d63cff3d261c971c221de6794d2","analyzedAt":"2026-08-21T18:22:53.330Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T05:18:18.240Z"}