{"record":{"id":"05156d9f622a1fde","repo":"dotnet/aspnetcore","slug":"dynamic-root-components-have-not-been-enabled-in-t","errorCode":null,"errorMessage":"Dynamic root components have not been enabled in this application.","messagePattern":"Dynamic root components have not been enabled in this application\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/Components/Web.JS/src/Rendering/JSRootComponents.ts","lineNumber":158,"sourceCode":"  if (!hasInitializedJsComponents) {\n    // Call the registered initializers. This is an arbitrary subset of the JS component types that are registered\n    // on the .NET side - just those of them that require some JS-side initialization (e.g., to register them\n    // as custom elements).\n    for (const [initializerIdentifier, componentIdentifiers] of Object.entries(jsComponentInitializers)) {\n      const initializerFunc = DotNet.findJSFunction(initializerIdentifier, 0) as JSComponentInitializerCallback;\n      for (const componentIdentifier of componentIdentifiers) {\n        const parameters = jsComponentParameters[componentIdentifier];\n        initializerFunc(componentIdentifier, parameters);\n      }\n    }\n\n    hasInitializedJsComponents = true;\n  }\n}\n\nfunction getRequiredManager(): DotNet.DotNetObject {\n  if (!manager) {\n    throw new Error('Dynamic root components have not been enabled in this application.');\n  }\n\n  return manager;\n}\n\n// Keep in sync with equivalent in JSComponentConfigurationStore.cs\n// These are an internal implementation detail not exposed in the registration APIs.\nexport type JSComponentParametersByIdentifier = { [identifier: string]: JSComponentParameter[] };\nexport type JSComponentIdentifiersByInitializer = { [initializer: string]: string[] };\n\n// The following is public API\nexport interface JSComponentInitializerCallback {\n  (identifier: string, parameters: JSComponentParameter[]): void;\n}\n\nexport interface JSComponentParameter {\n  name: string;\n  type: JSComponentParameterType;","sourceCodeStart":140,"sourceCodeEnd":176,"githubUrl":"https://github.com/dotnet/aspnetcore/blob/294cab2f9b2e03af6b953820c7ab497c3c8b7ad9/src/Components/Web.JS/src/Rendering/JSRootComponents.ts#L140-L176","documentation":"Thrown by getRequiredManager (used by RootComponentsFunctions.add and DynamicRootComponent.setParameters/dispose) when manager is undefined — i.e. enableJSRootComponents was never called for this page. Dynamic root component APIs require the framework to have wired up the .NET-side JSComponentConfigurationStore first.","triggerScenarios":"Calling Blazor.rootComponents.add or setParameters before/without the Blazor app having registered any JS root components on the .NET side (no RegisterForJavaScript calls, or Blazor not started).","commonSituations":"Calling rootComponents.add in a pure static-SSR app with no interactive rendermode; calling it before Blazor.start() completes; app didn't call AddOrCreate the JS component registrations server-side.","solutions":["Register at least one JS root component on the .NET side (builder.RegisterForJavaScript) so enableJSRootComponents runs.","Ensure Blazor has fully started before calling rootComponents.add.","Use an interactive rendermode (Server/WebAssembly/Auto) so the JS root component manager initializes."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Ensure enableJSRootComponents ran before adding.\n// Equivalent guard: only call add after Blazor started with JS root registrations.\nawait Blazor.start();\n// .NET side must have RegisterForJavaScript for at least one component.\nif (!rootComponentsEnabled) { throw new Error('Enable JS root components first'); }\nawait Blazor.rootComponents.add(el, 'MyComponent', {});","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Register at least one JS root component server-side (RegisterForJavaScript).","Wait for Blazor.start() to complete before calling rootComponents.add.","Use an interactive rendermode so the JS component manager initializes."],"tags":["blazor","root-components","initialization"],"analyzedSha":"294cab2f9b2e03af6b953820c7ab497c3c8b7ad9","analyzedAt":"2026-08-06T20:08:02.189Z","schemaVersion":2},"datasetVersion":"2026-08-06T23:17:07.152Z"}