0

I am developing a micro frontend app using single spa and react. I have created a utility module for data sharing and have loaded it in the root url /. But each time I change the application URL, the utility module is getting reinitialized. Is there any way to prevent the utility module from getting unmounted so that I can persist data across applications?

  • If your goal is to share data between URLs, then why did you attach the module to an URL? – Guerric P May 17 '21 at 12:00
  • @GuerricP My goal is to share data between individual apps running inside the single-spa framework. In such a scenario, don't I have to attach that to any URL? – Lawrence Moraira May 17 '21 at 19:01
  • @LawrenceMoraira Not sure what exactly you mean by unmounting when you are referring utility module. Assuming your utility module would be a simple in-browser module that you would be loading with systemjs in the index file unless you are using some framework for the utility module as well. – roanjain May 18 '21 at 17:06
  • I agree with @roanjain. There shouldn't be any reason to tie a utility module to a URL like single-spa applications do. – filoxo May 24 '21 at 17:19
  • Got the solution. Thanks – Lawrence Moraira Jun 07 '21 at 19:54
  • And do you probably want to share your solution? – Dennis de Laat Jan 31 '22 at 14:28
  • @dennis-de-laat I think the solution is to import utility module in root-config, and pass util module exports as custom props to applications, like so: https://www.linkedin.com/pulse/single-spa-authentication-state-management-using-react-rolando-niub%C3%B3/ – Shura Mar 13 '22 at 08:50

0 Answers0