withastro/astro · error · Error

context.params don't contain any usable content in Astro.

Error message

context.params don't contain any usable content in Astro.

What it means

In the dev mock context, `params` is `get params(): never` that throws because Astro owns route params via `Astro.params`. Netlify's `context.params` (used for catch-all routes in Netlify Functions) carries no usable data in Astro's routing model and is intentionally disabled.

Source

Thrown at packages/integrations/netlify/src/index.ts:604

					? req.headers['x-nf-client-connection-ip']
					: (req.socket.remoteAddress ?? '127.0.0.1'),
			server: {
				region: 'local-dev',
			},
			requestId:
				typeof req.headers['x-nf-request-id'] === 'string'
					? req.headers['x-nf-request-id']
					: 'mock-netlify-request-id',
			get cookies(): never {
				throw new Error('Please use Astro.cookies instead.');
			},
			json: (input) => Response.json(input),
			log: console.info,
			next: () => {
				throw new Error('`context.next` is not implemented for serverless functions');
			},
			get params(): never {
				throw new Error("context.params don't contain any usable content in Astro.");
			},
			rewrite() {
				throw new Error('context.rewrite is not available in Astro.');
			},
		};

		return context;
	}

	let routes: IntegrationResolvedRoute[];

	return {
		name: '@astrojs/netlify',
		hooks: {
			'astro:config:setup': async ({ config, updateConfig, logger, command }) => {
				rootDir = config.root;
				await cleanFunctions();

View on GitHub (pinned to d081033d5f)

Solutions

  1. Use `Astro.params` for route parameters.
  2. Use `Astro.url.searchParams` for query string.
  3. Remove reads of `context.params` from dev paths.

Example fix

// before
const { slug } = context.params;

// after
const { slug } = Astro.params;
Defensive patterns

Strategy: validation

Validate before calling

function getParams(Astro: any): Record<string, string> {
  return Astro.params;
}

Type guard

function hasAstroParams(Astro: any): Astro is { params: Record<string, string | undefined> } {
  return !!Astro?.params && typeof Astro.params === 'object';
}

Prevention

When it happens

Trigger: Reading `context.params` in an Astro handler in dev. Reused Netlify Function code that destructures `context.params`. Debug enumeration of the context object.

Common situations: Porting Netlify catch-all Function code. Code written against Netlify's `context.params.something` pattern.

Related errors


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