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
The mock dev Context exposes params as a throwing getter because Astro routing (not Netlify) owns route params in this setup; the Netlify Context never carries usable path parameters, so reading context.params is rejected instead of returning empty or stale data.
Solutions
- Read route params from Astro.params (or context.params on Astro's middleware context)
- Pass explicit values through locals when sharing data with helper functions
- Remove Netlify Context param reads; they will never be populated in Astro
Example fix
// before
const { slug } = locals.runtime.context.params;
// after
const { slug } = Astro.params; Defensive patterns
Strategy: fallback
Validate before calling
const ctx = locals.runtime?.context; const isLocalDev = ctx?.deploy?.context === 'dev'; const slug = isLocalDev ? Astro.params.slug : (ctx!.params?.slug ?? Astro.params.slug);
Type guard
function safeNetlifyParams<P extends Record<string, any>>(context: any, fallback: P): P {
try {
return { ...fallback, ...(context.params ?? {}) };
} catch {
return fallback;
}
} Try / catch
let params = Astro.params;
try {
params = { ...params, ...locals.runtime.context.params };
} catch {
// params getter throws in dev; Astro.params is authoritative anyway
} Prevention
- Always read route params from Astro.params
- Pass explicit arguments to helpers instead of re-deriving them from the Netlify Context
- Never assume the adapter forwards routing data into context
When it happens
Trigger: Destructuring or reading locals.runtime.context.params (e.g. const { slug } = context.params) in a page or endpoint during astro dev with the Netlify adapter.
Common situations: Functions code that used Netlify path parameters; assuming the adapter forwards route params into the Netlify Context; API helpers that try both Astro.params and context.params.
Related errors
- context.rewrite is not available in Astro.
- `context.next` is not implemented for serverless functions
- Please use Astro.cookies instead.
- Please use Astro.url instead.
- Missing parameter
AI-assisted analysis of withastro/astro@3578d45d34 (2026-08-18).
Data as JSON: /api/errors/9b171bb9a246e02e.
Report an issue: GitHub.
Appendix: 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 3578d45d34)