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
- Use `Astro.params` for route parameters.
- Use `Astro.url.searchParams` for query string.
- 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
- Read route params via `Astro.params`.
- Use `Astro.url.searchParams` for query strings.
- Do not read `context.params` in Astro handlers.
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
- Please use Astro.url instead.
- Please use Astro.cookies instead.
- context.rewrite is not available in Astro.
- `context.next` is not implemented for serverless functions
- [RSS] You can only glob entries within 'src/pages/' when pas
AI-assisted analysis of withastro/astro@d081033d5f (2026-08-12).
Data as JSON: /api/errors/9b171bb9a246e02e.
Report an issue: GitHub.