{"record":{"id":"8c601e5da25a9a4d","repo":"vuejs/vue","slug":"render-function-or-template-not-defined-in-compone","errorCode":null,"errorMessage":"render function or template not defined in component: ${vm.$options.name || vm.$options._componentTag || 'anonymous'}","messagePattern":"render function or template not defined in component: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/server-renderer/src/render.ts","lineNumber":49,"sourceCode":"}\n\nconst normalizeRender = vm => {\n  const { render, template, _scopeId } = vm.$options\n  if (isUndef(render)) {\n    if (template) {\n      const compiled = ssrCompileToFunctions(\n        template,\n        {\n          scopeId: _scopeId,\n          warn: onCompilationError\n        },\n        vm\n      )\n\n      vm.$options.render = compiled.render\n      vm.$options.staticRenderFns = compiled.staticRenderFns\n    } else {\n      throw new Error(\n        `render function or template not defined in component: ${\n          vm.$options.name || vm.$options._componentTag || 'anonymous'\n        }`\n      )\n    }\n  }\n}\n\nfunction waitForServerPrefetch(vm, resolve, reject) {\n  let handlers = vm.$options.serverPrefetch\n  if (isDef(handlers)) {\n    if (!Array.isArray(handlers)) handlers = [handlers]\n    try {\n      const promises: Promise<any>[] = []\n      for (let i = 0, j = handlers.length; i < j; i++) {\n        const result = handlers[i].call(vm, vm)\n        if (result && typeof result.then === 'function') {\n          promises.push(result)","sourceCodeStart":31,"sourceCodeEnd":67,"githubUrl":"https://github.com/vuejs/vue/blob/9e88707940088cb1f4cd7dd210c9168a50dc347c/packages/server-renderer/src/render.ts#L31-L67","documentation":"Thrown by normalizeRender during SSR when a component instance has neither a render function nor a template in its $options. The SSR renderer must produce VNodes; without a render or template it cannot. The component name is included (or 'anonymous' if unset, or _componentTag if a tag was used in the parent template).","triggerScenarios":"An SSR'd component has $options.render === undefined and $options.template === undefined. This happens with components that only define a render function conditionally, components that rely on a mixin/template loader that didn't run on the server, or empty placeholder components.","commonSituations":"A component imported on the client via a render function that is stripped by tree-shaking. A functional component missing its render. Using a component definition that is just { name: 'Foo' } with no template/render. A vue-loader misconfiguration drops the render/template at build time for SSR.","solutions":["Add a render function or template to the component's options.","If the component is meant to be renderless, give it a no-op render: { render: h => h() }.","Ensure vue-loader's SSR build emits the render function; check that the .vue file has a <template> or a render in <script>.","Verify the component is the one named in the error (trace the parent that mounts it)."],"exampleFix":"// before\nexport default { name: 'MyComponent' }\n\n// after\nexport default {\n  name: 'MyComponent',\n  render(h) {\n    return h('div', this.$slots.default)\n  }\n}","handlingStrategy":"validation","validationCode":"function assertComponentRenderable(vm: any): void {\n  const { render, template } = vm.$options\n  if (render === undefined && template === undefined) {\n    throw new Error(\n      `Component ${vm.$options.name || 'anonymous'} has no render function and no template; ` +\n      `cannot SSR. Add a <template> or render(h) to the component.`\n    )\n  }\n}\n\n// before SSR\nassertComponentRenderable(app)","typeGuard":"function isRenderableComponent(opts: any): boolean {\n  return typeof opts.render === 'function' || typeof opts.template === 'string'\n}","tryCatchPattern":"renderer.renderToString(app, (err, html) => {\n  if (err && err.message.includes('render function or template not defined in component')) {\n    // the component name is in the message; find it and add a render\n    console.error(err.message)\n  }\n})","preventionTips":["Ensure every component registered for SSR has either a <template> block or a render function.","For renderless/abstract components used only for logic, provide a no-op render: () => h().","Audit the component tree at startup and reject any component missing both render and template.","Run SSR smoke tests in CI to catch missing-render issues before deploy."],"tags":["ssr","component","render","template","missing"],"analyzedSha":"9e88707940088cb1f4cd7dd210c9168a50dc347c","analyzedAt":"2026-08-11T22:22:01.295Z","schemaVersion":2},"datasetVersion":"2026-08-12T04:17:13.124Z"}