Skip to content

Keycloak in Angular Micro-Frontends with Native Federation — Injector / Provider Issues #989

@jesussanzdev

Description

@jesussanzdev

For which library do you need help?

native-federation

Question

Hello angular-architects!

We are exploring the use of keycloak-angular in Angular v20 applications with a Micro-Frontend architecture using @angular-architects/native-federation.

Problem observed:

Angular often reports errors such as:
NG0201: No provider found for Keycloak or issues similar to those described in mauriciovigolo/keycloak-angular#432
and mauriciovigolo/keycloak-angular#465.

These issues appear only in MFE contexts before skipping Keycloak libraries. Monolithic applications work as expected. From what we have observed, a common recommendation is to enable a single auth library or shared service, skip the Keycloak libraries from the federation configuration, and share authentication information through that channel.

Context / observations:

Keycloak was primarily designed for monolithic Angular applications.

Multiple GitHub issues (e.g., mauriciovigolo/keycloak-angular#432) indicate challenges when sharing keycloak-js or keycloak-angular across hosts and remotes.

Deprecations in v20 removed some services that previously allowed custom DI or singleton patterns. This limits the ways Keycloak can be initialized before bootstrapping the host and remote applications.

Questions:

  • Is using keycloak-angular officially supported in Micro-Frontend architectures with Native Federation?
  • If yes, what is the recommended pattern to ensure that a Keycloak instance is properly available in Angular’s injector for host and remotes?
  • Is sharing keycloak-js or keycloak-angular as a singleton recommended or unsupported in these setups?
  • Is there an official DI token (e.g., KEYCLOAK_INSTANCE) for this purpose in v20?
  • Any official guidance or recommended patterns would be greatly appreciated.

References:

  1. Issue: Question: Keycloak with Module Federation mauriciovigolo/keycloak-angular#432
  2. Issue: MFE WEBPACK_IMPORTED_MODULE_5 is not a constructor mauriciovigolo/keycloak-angular#465
  3. Issue: Keycloak Angular Integration #736
  4. Blog: Micro Frontends with Angular and Native Federation
  5. Keycloak v20 release notes — deprecations affecting DI patterns: https://github.com/mauriciovigolo/keycloak-angular/releases

Any help or context is appreciated, thanks!

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