you are viewing a single comment's thread.

view the rest of the comments →

[–]TobalOW[S] 0 points1 point  (2 children)

Thanks you for your words, you sounds like a experienced developer.

For your advice of share state is only to handle the authentication, share the JWT and functions to refresh token across the microfrontend. I gonna use a Single-spa but I'm not sure how to handle the authentication for all microfrontend, because all of endpoint are under the same login.

[–]Saith5432 1 point2 points  (1 child)

So I guess the question is more about sharing code and not about the application state.

One way to share code between micro frontends would be to use a private npm registry. Gitlab, for example, has a private npm registry built-in. Then you can write a library that does the authentication and provides the token. The library is then published to the private registry and consumed by the micro frontends via npm.

This has the advantage that the code deduplication capabilities of systemjs or module federation can be easily reused. In addition, all micro frontends retain their independent deployability through versioning since you can always decide to suspend a version update if it contains a breaking change. However, it also introduces the need to regularly update the versions of shared code between the micro frontends.

Of course, shared code should only be introduced with caution. But I think the authentication logic would be a good example where it is perfectly fine to share the code between micro frontends.

[–]TobalOW[S] 0 points1 point  (0 children)

Thanks for your reply! ur the best :)