DEV Community

Cover image for From Monolithic To Micro Frontends - Part 3
AbdelRahman Hussein Mahmoud
AbdelRahman Hussein Mahmoud

Posted on


From Monolithic To Micro Frontends - Part 3

Table Of Contents

This will be the last part of the series and, we will see how can we register our Angular application inside our React application.


  • Inside your Angular application open main.single-spa.ts file, and insert this line of code
import "zone.js/dist/zone.js";
Enter fullscreen mode Exit fullscreen mode
  • Run your Angular application
npm run serve:single-spa:angular-app
Enter fullscreen mode Exit fullscreen mode

And now you should have your Angular application running and its main.js file serving using this URL: http://localhost:4200/main.js

Application Registration

To register your Angular application you will need to use systemjs to load your Angular application module from the URL

Note: if you used systemjs directly to import your module inside your React application you might face this error
'System.import' is restricted from being used. Please use import(), so we will use a workaround to register the application.


  • Open index.html inside the public folder, and add these scripts which are responsible to load systemjs library
<script src=""></script>
<script src=""></script>
<script src=""></script>
<script src=""></script>
Enter fullscreen mode Exit fullscreen mode
  • Create our import map JSON object, which will contain a key value for our Angular application the key will be a unique name and the value will be the URL of the module, and also will contain the shared dependencies, read more about it from here
<script type="systemjs-importmap">
    "imports": {
      "single-spa": "",
      "react": "",
      "react-dom": "",
      "@angularApp": "http://localhost:4200/main.js"
Enter fullscreen mode Exit fullscreen mode
  • Create a new script tag and inside it, we will define our function which will be used to load our Angular application module
   window["@angularApp"] = () => System.import("@angularApp");
Enter fullscreen mode Exit fullscreen mode

The final result for index.html should be like this


  • Open index.js file inside your React application and, add this snippet to register your application before start()
  (location) => true
Enter fullscreen mode Exit fullscreen mode

The final result for index.js should be like this

Start The Application

Now run your React application using the same script

npm start
Enter fullscreen mode Exit fullscreen mode

and your application should be started and working fine, you can access it using this URL: http://localhost:3000/.
Now the two applications are running on the same page. you can control when to load or unload the application from the DOM by implementing the activity function inside registerApplication for more info check the documentation, in my case, I want to run the two applications on the same page, so I just returned true.


Alright, that is all for now, and I hope it was useful for you. You should now have a basic knowledge of what is micro frontends and how single-spa managed it. Also, I will leave below some references you can get back to it anytime.

Top comments (2)

livialima12 profile image

This is an incredible well made content. Thank you and congrats

yogeshmali44 profile image

Great stuff... Can you make something similar for 2 separate Angular 10 apps ?