Skip to content

Lazy-loaded routes not working in single-spa setup with Angular 19 #546

@karanmobilesentrix

Description

@karanmobilesentrix

I’ve configured a single-spa root application along with two Angular 19 applications. The basic route configuration works fine when directly assigning components:

export const routes: Routes = [
  {
    path: "users",
    component: UsersComponent
  }
]

However, when I try to use lazy-loaded routes, the routing does not work as expected:

export const routes: Routes = [
  {
    path: "users",
    loadChildren: () =>
      import("./users/users.routes").then((m) => m.users)
  }
]

In main.single-spa.ts added as below

const lifecycles = singleSpaAngular({
    bootstrapFunction: (singleSpaProps) => {
        return bootstrapApplication(AppComponent, {
            providers: [
                ...getSingleSpaExtraProviders(),
                ...appConfig.providers,
                { provide: APP_BASE_HREF, useValue: '/user' },
            ],
        });
    },
    template: '<app-user />',
    Router,
    NgZone,
});

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions