Giter Site home page Giter Site logo

Comments (1)

joeldenning avatar joeldenning commented on September 27, 2024

How to share current user information to sub-applications after logging in from the main application?

Three options:

  1. Use single-spa custom props, which were created for this purpose
  2. Use a global variable window.loggedInUser. I've done this before and it's not bad as long as you don't end up modifying the global variables.
  3. Create a module in the import map called auth that exports a variable called user. Applications then use this variable via import {user} from 'auth'. Make sure to exclude auth from your webpack build by adding auth as a webpack external

Are there any other better ways besides localStorage?

Yes, I think all of the options listed above are better than localStorage, since making auth data persist when you reload the page can lead to funky bugs. Auth data is better checked from a cookie and the API rather than a local storage value that can become stale.

If the application is internationalized, how do other applications listen after the main application switches languages?

Internationalization can be done in the same way described in the Angular docs. In those docs, it suggests creating a separate bundle for each locale, along with a distinct base url inside the browser for each locale. Since each locale has entirely separate js files, you'll need to do a full page reload when switching locales. A full page reload can be accomplished with <a href="/fr"></a> iirc

I am closing this issue since I've answered the questions. Feel free to reopen or comment further with any other discussion related to this.

from coexisting-angular-microfrontends.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.