{"record":{"id":"8ccc4cc848776b16","repo":"withastro/astro","slug":"the-renderer-name-must-be-provided-when-adding-a-s","errorCode":null,"errorMessage":"The renderer name must be provided when adding a server renderer that is not a named renderer.","messagePattern":"The renderer name must be provided when adding a server renderer that is not a named renderer\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/astro/src/container/index.ts","lineNumber":418,"sourceCode":"\t\tconst { renderer } = options;\n\t\tif (!renderer.check || !renderer.renderToStaticMarkup) {\n\t\t\tthrow new Error(\n\t\t\t\t\"The renderer you passed isn't valid. A renderer is usually an object that exposes the `check` and `renderToStaticMarkup` functions.\\n\" +\n\t\t\t\t\t\"Usually, the renderer is exported by a /server.js entrypoint e.g. `import renderer from '@astrojs/react/server.js'`\",\n\t\t\t);\n\t\t}\n\t\tif (isNamedRenderer(renderer)) {\n\t\t\tthis.#manifest.renderers.push({\n\t\t\t\tname: renderer.name,\n\t\t\t\tssr: renderer,\n\t\t\t});\n\t\t} else if ('name' in options) {\n\t\t\tthis.#manifest.renderers.push({\n\t\t\t\tname: options.name,\n\t\t\t\tssr: renderer,\n\t\t\t});\n\t\t} else {\n\t\t\tthrow new Error(\n\t\t\t\t'The renderer name must be provided when adding a server renderer that is not a named renderer.',\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Use this function to manually add a **client** renderer to the container.\n\t *\n\t * When rendering components that use the `client:*` directives, you need to use this function.\n\t *\n\t * ## Example\n\t *\n\t * ```js\n\t * import reactRenderer from \"@astrojs/react/server.js\";\n\t * import { experimental_AstroContainer as AstroContainer } from \"astro/container\"\n\t *\n\t * const container = await AstroContainer.create();\n\t * container.addServerRenderer(reactRenderer);","sourceCodeStart":400,"sourceCodeEnd":436,"githubUrl":"https://github.com/withastro/astro/blob/3578d45d34226d63cff3d261c971c221de6794d2/packages/astro/src/container/index.ts#L400-L436","documentation":"`addServerRenderer` registers a renderer in the container's manifest under a name. If the renderer object is not 'named' (has no `name` property of its own) and no `name` was supplied in the options object, there is nothing to key the renderer by — client renderers are later matched by this exact name — so the call is rejected.","triggerScenarios":"`addServerRenderer({ renderer })` where the renderer object lacks a `name` field — typical for anonymous/custom server renderers built inline in test setup; destructuring or cloning a renderer without carrying `name` over.","commonSituations":"Custom renderers in container tests; integrations exporting anonymous renderer objects; refactors that wrap a renderer in a new object and drop the `name` property.","solutions":["Pass the name explicitly: `addServerRenderer({ name: '@astrojs/react', renderer })`","Or give the renderer object itself a `name` property (named renderers are detected automatically)","Use the package name as the name — `addClientRenderer` later matches the server renderer by that same name"],"exampleFix":"// before\ncontainer.addServerRenderer({ renderer: { check, renderToStaticMarkup } });\n\n// after\ncontainer.addServerRenderer({\n  name: 'my-renderer',\n  renderer: { check, renderToStaticMarkup },\n});","handlingStrategy":"type-guard","validationCode":null,"typeGuard":"function rendererHasName(renderer, options) {\n  return typeof renderer?.name === 'string' || typeof options?.name === 'string';\n}\n\nconst options = { renderer };\nif (!rendererHasName(renderer, options)) {\n  options.name = 'my-renderer'; // supply the missing name\n}\ncontainer.addServerRenderer(options);","tryCatchPattern":null,"preventionTips":["Always pass `name` explicitly in test helpers — conventionally the integration's package name","Keep the name consistent with what `addClientRenderer` will use, since client registration looks the server renderer up by name","When cloning or wrapping a renderer object, carry the `name` property over"],"tags":["container","renderers","missing-argument","testing","experimental"],"backgroundTag":"missing-required-option","analyzedSha":"3578d45d34226d63cff3d261c971c221de6794d2","analyzedAt":"2026-08-18T18:48:03.901Z","contentChangedAt":"2026-08-18T18:48:03.901Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}