withastro/astro · error · AstroError
ReservedSlotName
ReservedSlotName
Error message
Unable to create a slot named `${slotName}`. `${slotName}` is a reserved slot name. Please update the name of this slot. What it means
A named slot's name collided with an existing property on the Slots instance (e.g. 'has', 'render', 'result'). The Slots class defines accessors for each slot name, so names that shadow its own methods/fields are rejected to prevent breaking slot lookups.
Source
Thrown at packages/astro/src/core/render/slots.ts:36
return getFunctionExpression(expression);
}
return expression as (...args: any[]) => any;
}
export class Slots {
#result: SSRResult;
#slots: ComponentSlots | null;
#logger: AstroLogger;
constructor(result: SSRResult, slots: ComponentSlots | null, logger: AstroLogger) {
this.#result = result;
this.#slots = slots;
this.#logger = logger;
if (slots) {
for (const key of Object.keys(slots)) {
if ((this as any)[key] !== undefined) {
throw new AstroError({
...AstroErrorData.ReservedSlotName,
message: AstroErrorData.ReservedSlotName.message(key),
});
}
Object.defineProperty(this, key, {
get() {
return true;
},
enumerable: true,
});
}
}
}
public has(name: string) {
if (!this.#slots) return false;
return Boolean(this.#slots[name]);
}View on GitHub (pinned to d081033d5f)
Solutions
- Rename the slot to something that is not a property of the Slots class (avoid 'has', 'render', 'result', 'prop', etc.).
- Check the reserved collision by confirming the name is not already a method on the component's slot helper.
- Use a domain-specific prefix for slot names to avoid accidental collisions.
Example fix
// before <slot name="render" /> // after <slot name="content" />
Defensive patterns
Strategy: validation
Validate before calling
const RESERVED = new Set(['has','render','result','prop','name','length','constructor','prototype']);
function isReservedSlotName(name: string): boolean {
return RESERVED.has(name);
}
// guard slot names before defining them Type guard
function isSafeSlotName(name: string): boolean {
return !(['has','render','result','prop','name','length'] as string[]).includes(name);
} Prevention
- Avoid method-like slot names (has, render, result).
- Use domain-specific slot names (header, footer, content).
- When generating slots programmatically, validate against a reserved-name list.
When it happens
Trigger: Defining <slot name="has" />, <slot name="render" />, or any name matching a Slots prototype property; passing a slot whose name equals an internal method.
Common situations: Choosing slot names like 'name', 'length', 'render', 'has' that overlap with built-in object members; programmatic slot generation that picks reserved words.
Related errors
AI-assisted analysis of withastro/astro@d081033d5f (2026-08-12).
Data as JSON: /api/errors/862b2ede65bc75a2.
Report an issue: GitHub.