dotnet/aspnetcore · error · Error
Dynamic root components have not been enabled in this applic
Error message
Dynamic root components have not been enabled in this application.
What it means
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.
Source
Thrown at src/Components/Web.JS/src/Rendering/JSRootComponents.ts:158
if (!hasInitializedJsComponents) {
// Call the registered initializers. This is an arbitrary subset of the JS component types that are registered
// on the .NET side - just those of them that require some JS-side initialization (e.g., to register them
// as custom elements).
for (const [initializerIdentifier, componentIdentifiers] of Object.entries(jsComponentInitializers)) {
const initializerFunc = DotNet.findJSFunction(initializerIdentifier, 0) as JSComponentInitializerCallback;
for (const componentIdentifier of componentIdentifiers) {
const parameters = jsComponentParameters[componentIdentifier];
initializerFunc(componentIdentifier, parameters);
}
}
hasInitializedJsComponents = true;
}
}
function getRequiredManager(): DotNet.DotNetObject {
if (!manager) {
throw new Error('Dynamic root components have not been enabled in this application.');
}
return manager;
}
// Keep in sync with equivalent in JSComponentConfigurationStore.cs
// These are an internal implementation detail not exposed in the registration APIs.
export type JSComponentParametersByIdentifier = { [identifier: string]: JSComponentParameter[] };
export type JSComponentIdentifiersByInitializer = { [initializer: string]: string[] };
// The following is public API
export interface JSComponentInitializerCallback {
(identifier: string, parameters: JSComponentParameter[]): void;
}
export interface JSComponentParameter {
name: string;
type: JSComponentParameterType;View on GitHub (pinned to 294cab2f9b)
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.
Defensive patterns
Strategy: validation
Validate before calling
// Ensure enableJSRootComponents ran before adding.
// Equivalent guard: only call add after Blazor started with JS root registrations.
await Blazor.start();
// .NET side must have RegisterForJavaScript for at least one component.
if (!rootComponentsEnabled) { throw new Error('Enable JS root components first'); }
await Blazor.rootComponents.add(el, 'MyComponent', {}); Prevention
- 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.
When it happens
Trigger: 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).
Common situations: 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.
Related errors
- Invalid sequence number or identifier '${sequenceOrIdentifie
- initialParameters must be an object, even if empty.
- Dynamic root components have already been enabled.
- The '${beforeElementSelector}' selector is not supported.
- Could not find any element matching selector '${elementSelec
AI-assisted analysis of dotnet/aspnetcore@294cab2f9b (2026-08-06).
Data as JSON: /api/errors/05156d9f622a1fde.
Report an issue: GitHub.