withastro/astro · warning

getStaticPaths() ignored in dynamic page ${colors.bold(rootR

Error message

getStaticPaths() ignored in dynamic page ${colors.bold(rootRelativePath(settings.config.root, fileURL, true))}. Add `export const prerender = true;` to prerender the page as static HTML during the build process.

What it means

vite-plugin-routes does a literal string scan for `getStaticPaths` in route module code. If the route is not prerendered (e.g. output: 'server' without opt-in), getStaticPaths is dead code Astro never calls, so the plugin warns and points you to `export const prerender = true;` to make it effective. The check is a plain substring match limited to .astro/.js/.ts route files.

Source

Thrown at packages/astro/src/vite-plugin-routes/index.ts:256

			const fileIsEndpoint = isEndpoint(fileURL, settings);
			if (!(fileIsPage || fileIsEndpoint)) return;
			const route =
				this.environment.mode === 'build'
					? getRouteByFilename().get(filename)
					: findRouteByFilename(filename);

			if (!route) {
				return;
			}

			// `getStaticPaths` warning is just a string check, should be good enough for most cases
			if (
				!route.prerender &&
				code.includes('getStaticPaths') &&
				// this should only be valid for `.astro`, `.js` and `.ts` files
				KNOWN_FILE_EXTENSIONS.includes(extname(filename))
			) {
				logger.warn(
					'router',
					`getStaticPaths() ignored in dynamic page ${colors.bold(
						rootRelativePath(settings.config.root, fileURL, true),
					)}. Add \`export const prerender = true;\` to prerender the page as static HTML during the build process.`,
				);
			}

			const { meta = {} } = this.getModuleInfo(id) ?? {};
			return {
				code,
				map: null,
				meta: {
					...meta,
					astro: {
						...(meta.astro ?? createDefaultAstroMetadata()),
						pageOptions: {
							prerender: route.prerender,
						},

View on GitHub (pinned to e294953aa8)

Solutions

  1. Add `export const prerender = true;` to the page if it should be static
  2. Delete getStaticPaths if the page is meant to be dynamic — params then come from the request, not static generation
  3. Set output: 'static' in astro.config.mjs if the majority of pages should prerender
  4. For false positives, reword the comment/string so it no longer contains the literal token

Example fix

// before  src/pages/[slug].astro (output: 'server')
export async function getStaticPaths() { /* ignored: page is dynamic */ }

// after
export const prerender = true;
export async function getStaticPaths() { /* now runs at build */ }
Defensive patterns

Strategy: validation

Validate before calling

# List route files containing getStaticPaths that lack the prerender opt-in
for f in $(grep -rl 'getStaticPaths' src/pages --include='*.astro'); do
  grep -q 'prerender = true' "$f" || echo "missing prerender: $f"
done

Prevention

When it happens

Trigger: A page exports getStaticPaths while its route resolves to server-rendered: output: 'server' or 'hybrid' without `export const prerender = true`, or an explicit prerender = false in the same file. Also fires as a false positive when the literal text appears in a comment or string inside a dynamic route file.

Common situations: Copying a static page into a project defaulted to server output; flipping a page to dynamic but leaving getStaticPaths behind; mentioning getStaticPaths in a comment of a server route and getting the warning anyway.

Related errors


AI-assisted analysis of withastro/astro@e294953aa8 (2026-08-18). Data as JSON: /api/errors/c1faf08265fcc8c6. Report an issue: GitHub.