{"record":{"id":"862b2ede65bc75a2","repo":"withastro/astro","slug":"reservedslotname","errorCode":"ReservedSlotName","errorMessage":"Unable to create a slot named `${slotName}`. `${slotName}` is a reserved slot name. Please update the name of this slot.","messagePattern":"Unable to create a slot named `(.+?)`\\. `(.+?)` is a reserved slot name\\. Please update the name of this slot\\.","errorType":"exception","errorClass":"AstroError","httpStatus":null,"severity":"error","filePath":"packages/astro/src/core/render/slots.ts","lineNumber":36,"sourceCode":"\t\treturn getFunctionExpression(expression);\n\t}\n\treturn expression as (...args: any[]) => any;\n}\n\nexport class Slots {\n\t#result: SSRResult;\n\t#slots: ComponentSlots | null;\n\t#logger: AstroLogger;\n\n\tconstructor(result: SSRResult, slots: ComponentSlots | null, logger: AstroLogger) {\n\t\tthis.#result = result;\n\t\tthis.#slots = slots;\n\t\tthis.#logger = logger;\n\n\t\tif (slots) {\n\t\t\tfor (const key of Object.keys(slots)) {\n\t\t\t\tif ((this as any)[key] !== undefined) {\n\t\t\t\t\tthrow new AstroError({\n\t\t\t\t\t\t...AstroErrorData.ReservedSlotName,\n\t\t\t\t\t\tmessage: AstroErrorData.ReservedSlotName.message(key),\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t\tObject.defineProperty(this, key, {\n\t\t\t\t\tget() {\n\t\t\t\t\t\treturn true;\n\t\t\t\t\t},\n\t\t\t\t\tenumerable: true,\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\t}\n\n\tpublic has(name: string) {\n\t\tif (!this.#slots) return false;\n\t\treturn Boolean(this.#slots[name]);\n\t}","sourceCodeStart":18,"sourceCodeEnd":54,"githubUrl":"https://github.com/withastro/astro/blob/52e6c34790cc8ac4e69e6135ace06049867e5c4a/packages/astro/src/core/render/slots.ts#L18-L54","documentation":"At render time Astro wraps a component's slots in a `Slots` instance that exposes each slot name as a boolean property (`slots.has?.('name')` style access). The constructor defines each incoming slot name on the instance, but first rejects any name that already exists as a class member — `has`, `render`, and other prototype methods — because the slot flag would shadow the API. Using one of those names throws `ReservedSlotName`.","triggerScenarios":"`<MyComponent slot=\"render\">…</MyComponent>` or `slot=\"has\"`; passing children with those keys programmatically (JSX/MDX named slots); a design system renaming a generic slot to `render` or `has` in a new version, breaking consumers at build/dev render time.","commonSituations":"Generic wrapper components tempted to call a slot `render`; upgrading a UI library whose slot vocabulary grew into these names; MDX content using `slot` attributes that collide.","solutions":["Rename the slot to something not used by the Slots class (e.g. `renderSlot`, `hasContent`)","Update both the child (`slot=\"newName\"`) and the parent's `<slot name=\"newName\" />`","When wrapping third-party components, check their slot names against the reserved list (`has`, `render`, etc.)"],"exampleFix":"<!-- before -->\n<Layout slot=\"render\">…</Layout>\n\n<!-- after -->\n<Layout slot=\"main\">…</Layout>\n<!-- and in Layout.astro: <slot name=\"main\" /> -->","handlingStrategy":"type-guard","validationCode":"// Component library: validate slot names before passing them through\nconst slotsToPass = Object.fromEntries(\n  Object.entries(userSlots).filter(([name]) => isSafeSlotName(name)),\n);","typeGuard":"// Slot names must not collide with Slots class members\nconst RESERVED_SLOT_NAMES = new Set(['has', 'render', 'renderFederated', 'constructor']);\nexport function isSafeSlotName(name: string): boolean {\n  return !RESERVED_SLOT_NAMES.has(name);\n}","tryCatchPattern":null,"preventionTips":["Avoid `render`, `has`, and other API-sounding names when designing slot vocabularies","Smoke-render wrapper components once after renaming slots","Document reserved names in your component library's contribution guide"],"tags":["slots","components","rendering","naming"],"backgroundTag":"reserved-slot-name","analyzedSha":"52e6c34790cc8ac4e69e6135ace06049867e5c4a","analyzedAt":"2026-08-18T18:48:03.901Z","contentChangedAt":"2026-08-18T18:48:03.901Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}