SlideShare a Scribd company logo
2
Most read
3
Most read
5
Most read
How to Build a Micro-Application
using Single-Spa
By,
Shwetha Thomas, Senior Software Engineer
How to Build a Micro-Application using Single-Spa
© RapidValue Solutions 2
How to Create a Micro-Application using Single-Spa
Following are the steps to create a micro-application:
● Create an angular application with a unique prefix.
ng new --prefix app1
● Enter the command ng add single-spa-angular in our project which in turn will do the
following:
- Install single-spa-angular
- Generates a main.single-spa.ts in our project src/.
- Generates single-spa-props.ts in src/single-spa/
- Generates asset-url.ts in src/single-spa/
- Generates an EmptyRouteComponent in src/app/empty-route/, to be used in app-
routing.module.ts.
- Add an npm script npm run build:single-spa.
- Add an npm script npm run serve:single-spa.
● Install custom-webpack as dev dependency(npm install -D @angular-builders/custom-
webpack@9.1.0)
● Add providers: [{provide: APP_BASE_HREF, useValue: '/'}] to app-routing.module.ts
● Add {path: '**', component: EmptyRouteComponent} to our app-routing.module.ts routes.
● Add a declaration for EmptyRouteComponent in app.module.ts
● Register the micro-app in the index.html file and call single-spa.start() function.
For example,
How to Build a Micro-Application using Single-Spa
© RapidValue Solutions 3
Figure 1: Import single-spa
Here, we are using import maps to set the path for our micro-app. student is the micro app here
which we are registering. Since we are running locally, the localhosturl is given. Once we deploy
the micro app, we can replace local url by giving the deployed url. main.js is a javascript file with the
webpack which is created while running the app. While building the app, main-es2015.js file is
created in the dist folder with the webpack.
Figure 2: Register application
This script tag is given inside the body. Here we are registering the micro-app and then calling the
singleSpa.start(). In this example, the function returns true, which means the app will be loaded by
default. We can also specify a route, so the micro-app will be mounted only on calling the specific
route.
If the function returns, location.pathname.startsWith(‘/student’); student micro-app will be
loaded only on calling /student.
There are some script tags, which is needed on loading micro-apps which are given below:
<script src='https://unpkg.com/core-js-bundle@3.1.4/minified.js'></script>
How to Build a Micro-Application using Single-Spa
© RapidValue Solutions 4
<script src="https://unpkg.com/zone.js"></script>
<script src="https://unpkg.com/import-map-overrides@1.6.0/dist/import-map-overrides.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/systemjs/4.0.0/system.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/systemjs/4.0.0/extras/amd.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/systemjs/4.0.0/extras/named-exports.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/systemjs/4.0.0/extras/named-
register.min.js"></script>
Make sure each micro-app runs in a different port locally.
Serving a Micro-Application
To serve a micro-application, run the following command:
npm run serve:single-spa
For angular version greater than 9, app name will be appended to this command. Check the
package.json to know the exact command.
For example,
npm run serve:single-spa:app
Building a Micro-Application
.To build a micro-application, run the following command:
npm run build:single-spa
For angular version greater than 9, app name will be appended to this command. Check the
package.json to know the exact command.
How to Build a Micro-Application using Single-Spa
© RapidValue Solutions 5
For example,
npm run build:single-spa:app
This will create a dist folder.
How to Register the Micro-Apps into the Portal
We can load any number of micro-apps in a single application which is the portal. To create a portal application, we
need an HTML file where we can register our micro-apps and call singleSpa.start().
To register a micro-app into the portal,
● We must specify the main.js path of the micro-app in the portal
● Add the required scripts
● Register the micro-application
● Call singleSpa.start()
Take a look at the images given below for a better understanding.
Figure 1: Specify main.js path
How to Build a Micro-Application using Single-Spa
© RapidValue Solutions 6
Figure 2: Register micro-app and call start method
This part is the same as registering a micro-app to itself.
Following the above-mentioned steps ensures that the process of building and registering micro-applications in the
portal is as seamless as possible.
How to Build a Micro-Application using Single-Spa
© RapidValue Solutions 7
About RapidValue
RapidValue is a global leader in providing digital product engineering solutions including Mobility, Cloud,
Omni-channel, IoT and RPA to enterprises worldwide. RapidValue offers its digital services to the world’s
top brands, Fortune 1000 companies, and innovative emerging start-ups. With offices in the United
States, the United Kingdom, Germany, and India and operations spread across the Middle-East, Europe,
and Canada, RapidValue delivers enterprise service and solutions across various industry verticals.
Disclaimer:
This document contains information that is confidential and proprietary to RapidValue Solutions Inc. No part of it may be used,
circulated, quoted, or reproduced for distribution outside RapidValue. If you are not the intended recipient of this report, you are
hereby notified that the use, circulation, quoting, or reproducing of this report is strictly prohibited and may be unlawful.
© RapidValue Solutions
www.rapidvaluesolutions.com/blog
www.rapidvaluesolutions.com
+1 877.643.1850 contactus@rapidvaluesolutions.com

More Related Content

PDF
React with rails a perfect combination to build modern web application
PDF
MICRO-FRONTEND - WEB COMPONENT APPROACH
PDF
Spring Boot 2.2
PDF
Transporting Data at Warp Speed: How to Connect Spring Boot Apps Quickly, Pow...
PDF
Observability Enhancements in Steeltoe
PDF
Continuous Delivery de vos applications dans un environnement multi-cloud et ...
PDF
Building Cloud Native Architectures with Spring
PDF
Tutto quello che avreste voluto sapere sull'API Management (e non avete mai o...
React with rails a perfect combination to build modern web application
MICRO-FRONTEND - WEB COMPONENT APPROACH
Spring Boot 2.2
Transporting Data at Warp Speed: How to Connect Spring Boot Apps Quickly, Pow...
Observability Enhancements in Steeltoe
Continuous Delivery de vos applications dans un environnement multi-cloud et ...
Building Cloud Native Architectures with Spring
Tutto quello che avreste voluto sapere sull'API Management (e non avete mai o...

What's hot (20)

PDF
TDD for Microservices
PPTX
TUTTO SU VISUAL STUDIO ALM 2015
PDF
Extending the Platform with Spring Boot and Cloud Foundry
PPTX
Running Spring Boot in Kubernetes and Intro to Helm
PPTX
Bootiful Azure Spring Cloud
PPTX
Adapt or Die: A Microservices Story at Google
PPTX
Introduction To Micro Frontends
PDF
Make Spring Home (Spring Customization and Extensibility)
DOCX
Santosh Shukla-microservices-java-spring boot
PPTX
Firebase
PDF
BENEFIT OF FLUTTER APP DEVELOPMENT - INFOGRAPHICS
PDF
Pivotal Cloud Foundry et Microsoft: Pourquoi? ... Et pourquoi pas?
PDF
Breaking Down the Monolith - Peter Marton, RisingStack
PPTX
A Starters Guide to Building APIs with Javascript
PDF
Back your app with MySQL and Redis on Cloud Foundry
PPTX
Test Automation Workshop with BDD Approach
PDF
DevSecCon London 2019: Workshop: Cloud Agnostic Security Testing with Scout S...
PDF
Scaling with Microservices
PDF
[APIdays INTERFACE 2021] Now that we have K8s, can we stop re-inventing API p...
PDF
Integrate Machine Learning into Your Spring Application in Less than an Hour
TDD for Microservices
TUTTO SU VISUAL STUDIO ALM 2015
Extending the Platform with Spring Boot and Cloud Foundry
Running Spring Boot in Kubernetes and Intro to Helm
Bootiful Azure Spring Cloud
Adapt or Die: A Microservices Story at Google
Introduction To Micro Frontends
Make Spring Home (Spring Customization and Extensibility)
Santosh Shukla-microservices-java-spring boot
Firebase
BENEFIT OF FLUTTER APP DEVELOPMENT - INFOGRAPHICS
Pivotal Cloud Foundry et Microsoft: Pourquoi? ... Et pourquoi pas?
Breaking Down the Monolith - Peter Marton, RisingStack
A Starters Guide to Building APIs with Javascript
Back your app with MySQL and Redis on Cloud Foundry
Test Automation Workshop with BDD Approach
DevSecCon London 2019: Workshop: Cloud Agnostic Security Testing with Scout S...
Scaling with Microservices
[APIdays INTERFACE 2021] Now that we have K8s, can we stop re-inventing API p...
Integrate Machine Learning into Your Spring Application in Less than an Hour
Ad

Similar to How to Build a Micro-Application using Single-Spa (20)

PDF
Frontend Monoliths: Run if you can!
PPTX
The Benefits of Using Single Page Applications in Full Stack Development.pptx
PDF
The Benefits of Using Single Page Applications in Full Stack Development.pdf
PPTX
The Power of Single-Page Applications (SPAs) - Volga Tigris
PPTX
Micro frontend
PPTX
Building great spa’s with angular js, asp.net mvc and webapi
PPTX
SPA Philly Code Camp
PDF
The Characteristics of a Successful SPA
PPTX
A Complete Guidance to SPA vs MPA: Which is better?
PDF
DeltaFixes - Single Page Application Development Company
PPTX
What You Need to Know About Single-Page Applications for Your Business!
PPTX
Single Page Apps
PDF
Spa vs. Mpa- exploring the pros and cons
PPTX
Relax, it's spa time
PDF
Burgas Conf 21.06.2014 - Single page application Angularjs and Nodejs
PDF
SPA vs MVA
PPTX
The Power Of SPA - ISCTE
PPTX
Spas are dead Long Live Microfrontends
PDF
PPTX
Single page application
Frontend Monoliths: Run if you can!
The Benefits of Using Single Page Applications in Full Stack Development.pptx
The Benefits of Using Single Page Applications in Full Stack Development.pdf
The Power of Single-Page Applications (SPAs) - Volga Tigris
Micro frontend
Building great spa’s with angular js, asp.net mvc and webapi
SPA Philly Code Camp
The Characteristics of a Successful SPA
A Complete Guidance to SPA vs MPA: Which is better?
DeltaFixes - Single Page Application Development Company
What You Need to Know About Single-Page Applications for Your Business!
Single Page Apps
Spa vs. Mpa- exploring the pros and cons
Relax, it's spa time
Burgas Conf 21.06.2014 - Single page application Angularjs and Nodejs
SPA vs MVA
The Power Of SPA - ISCTE
Spas are dead Long Live Microfrontends
Single page application
Ad

More from RapidValue (20)

PDF
Play with Jenkins Pipeline
PDF
Accessibility Testing using Axe
PDF
Guide to Generate Extent Report in Kotlin
PDF
Automation in Digital Cloud Labs
PDF
Microservices Architecture - Top Trends & Key Business Benefits
PDF
Uploading Data Using Oracle Web ADI
PDF
Appium Automation with Kotlin
PDF
Build UI of the Future with React 360
PDF
Python Google Cloud Function with CORS
PDF
Real-time Automation Result in Slack Channel
PDF
Automation Testing with KATALON Cucumber BDD
PDF
How to Implement Micro Frontend Architecture using Angular Framework
PDF
Video Recording of Selenium Automation Flows
PDF
JMeter JMX Script Creation via BlazeMeter
PDF
Migration to Extent Report 4
PDF
The Definitive Guide to Implementing Shift Left Testing in QA
PDF
Data Seeding via Parameterized API Requests
PDF
Test Case Creation in Katalon Studio
PDF
How to Perform Memory Leak Test Using Valgrind
PDF
DevOps Continuous Integration & Delivery - A Whitepaper by RapidValue
Play with Jenkins Pipeline
Accessibility Testing using Axe
Guide to Generate Extent Report in Kotlin
Automation in Digital Cloud Labs
Microservices Architecture - Top Trends & Key Business Benefits
Uploading Data Using Oracle Web ADI
Appium Automation with Kotlin
Build UI of the Future with React 360
Python Google Cloud Function with CORS
Real-time Automation Result in Slack Channel
Automation Testing with KATALON Cucumber BDD
How to Implement Micro Frontend Architecture using Angular Framework
Video Recording of Selenium Automation Flows
JMeter JMX Script Creation via BlazeMeter
Migration to Extent Report 4
The Definitive Guide to Implementing Shift Left Testing in QA
Data Seeding via Parameterized API Requests
Test Case Creation in Katalon Studio
How to Perform Memory Leak Test Using Valgrind
DevOps Continuous Integration & Delivery - A Whitepaper by RapidValue

Recently uploaded (20)

PDF
Designing Intelligence for the Shop Floor.pdf
PDF
AutoCAD Professional Crack 2025 With License Key
PPTX
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
PDF
Digital Systems & Binary Numbers (comprehensive )
PDF
iTop VPN Free 5.6.0.5262 Crack latest version 2025
PDF
How to Make Money in the Metaverse_ Top Strategies for Beginners.pdf
PDF
iTop VPN 6.5.0 Crack + License Key 2025 (Premium Version)
PPTX
Advanced SystemCare Ultimate Crack + Portable (2025)
PDF
Download FL Studio Crack Latest version 2025 ?
PPTX
Log360_SIEM_Solutions Overview PPT_Feb 2020.pptx
PDF
Adobe Premiere Pro 2025 (v24.5.0.057) Crack free
PPTX
assetexplorer- product-overview - presentation
PDF
Navsoft: AI-Powered Business Solutions & Custom Software Development
PDF
Odoo Companies in India – Driving Business Transformation.pdf
PDF
Tally Prime Crack Download New Version 5.1 [2025] (License Key Free
PPTX
Patient Appointment Booking in Odoo with online payment
PDF
wealthsignaloriginal-com-DS-text-... (1).pdf
PDF
CCleaner Pro 6.38.11537 Crack Final Latest Version 2025
PPTX
AMADEUS TRAVEL AGENT SOFTWARE | AMADEUS TICKETING SYSTEM
PDF
Adobe Illustrator 28.6 Crack My Vision of Vector Design
Designing Intelligence for the Shop Floor.pdf
AutoCAD Professional Crack 2025 With License Key
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
Digital Systems & Binary Numbers (comprehensive )
iTop VPN Free 5.6.0.5262 Crack latest version 2025
How to Make Money in the Metaverse_ Top Strategies for Beginners.pdf
iTop VPN 6.5.0 Crack + License Key 2025 (Premium Version)
Advanced SystemCare Ultimate Crack + Portable (2025)
Download FL Studio Crack Latest version 2025 ?
Log360_SIEM_Solutions Overview PPT_Feb 2020.pptx
Adobe Premiere Pro 2025 (v24.5.0.057) Crack free
assetexplorer- product-overview - presentation
Navsoft: AI-Powered Business Solutions & Custom Software Development
Odoo Companies in India – Driving Business Transformation.pdf
Tally Prime Crack Download New Version 5.1 [2025] (License Key Free
Patient Appointment Booking in Odoo with online payment
wealthsignaloriginal-com-DS-text-... (1).pdf
CCleaner Pro 6.38.11537 Crack Final Latest Version 2025
AMADEUS TRAVEL AGENT SOFTWARE | AMADEUS TICKETING SYSTEM
Adobe Illustrator 28.6 Crack My Vision of Vector Design

How to Build a Micro-Application using Single-Spa

  • 1. How to Build a Micro-Application using Single-Spa By, Shwetha Thomas, Senior Software Engineer
  • 2. How to Build a Micro-Application using Single-Spa © RapidValue Solutions 2 How to Create a Micro-Application using Single-Spa Following are the steps to create a micro-application: ● Create an angular application with a unique prefix. ng new --prefix app1 ● Enter the command ng add single-spa-angular in our project which in turn will do the following: - Install single-spa-angular - Generates a main.single-spa.ts in our project src/. - Generates single-spa-props.ts in src/single-spa/ - Generates asset-url.ts in src/single-spa/ - Generates an EmptyRouteComponent in src/app/empty-route/, to be used in app- routing.module.ts. - Add an npm script npm run build:single-spa. - Add an npm script npm run serve:single-spa. ● Install custom-webpack as dev dependency(npm install -D @angular-builders/custom- [email protected]) ● Add providers: [{provide: APP_BASE_HREF, useValue: '/'}] to app-routing.module.ts ● Add {path: '**', component: EmptyRouteComponent} to our app-routing.module.ts routes. ● Add a declaration for EmptyRouteComponent in app.module.ts ● Register the micro-app in the index.html file and call single-spa.start() function. For example,
  • 3. How to Build a Micro-Application using Single-Spa © RapidValue Solutions 3 Figure 1: Import single-spa Here, we are using import maps to set the path for our micro-app. student is the micro app here which we are registering. Since we are running locally, the localhosturl is given. Once we deploy the micro app, we can replace local url by giving the deployed url. main.js is a javascript file with the webpack which is created while running the app. While building the app, main-es2015.js file is created in the dist folder with the webpack. Figure 2: Register application This script tag is given inside the body. Here we are registering the micro-app and then calling the singleSpa.start(). In this example, the function returns true, which means the app will be loaded by default. We can also specify a route, so the micro-app will be mounted only on calling the specific route. If the function returns, location.pathname.startsWith(‘/student’); student micro-app will be loaded only on calling /student. There are some script tags, which is needed on loading micro-apps which are given below: <script src='https://unpkg.com/[email protected]/minified.js'></script>
  • 4. How to Build a Micro-Application using Single-Spa © RapidValue Solutions 4 <script src="https://unpkg.com/zone.js"></script> <script src="https://unpkg.com/[email protected]/dist/import-map-overrides.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/systemjs/4.0.0/system.min.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/systemjs/4.0.0/extras/amd.min.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/systemjs/4.0.0/extras/named-exports.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/systemjs/4.0.0/extras/named- register.min.js"></script> Make sure each micro-app runs in a different port locally. Serving a Micro-Application To serve a micro-application, run the following command: npm run serve:single-spa For angular version greater than 9, app name will be appended to this command. Check the package.json to know the exact command. For example, npm run serve:single-spa:app Building a Micro-Application .To build a micro-application, run the following command: npm run build:single-spa For angular version greater than 9, app name will be appended to this command. Check the package.json to know the exact command.
  • 5. How to Build a Micro-Application using Single-Spa © RapidValue Solutions 5 For example, npm run build:single-spa:app This will create a dist folder. How to Register the Micro-Apps into the Portal We can load any number of micro-apps in a single application which is the portal. To create a portal application, we need an HTML file where we can register our micro-apps and call singleSpa.start(). To register a micro-app into the portal, ● We must specify the main.js path of the micro-app in the portal ● Add the required scripts ● Register the micro-application ● Call singleSpa.start() Take a look at the images given below for a better understanding. Figure 1: Specify main.js path
  • 6. How to Build a Micro-Application using Single-Spa © RapidValue Solutions 6 Figure 2: Register micro-app and call start method This part is the same as registering a micro-app to itself. Following the above-mentioned steps ensures that the process of building and registering micro-applications in the portal is as seamless as possible.
  • 7. How to Build a Micro-Application using Single-Spa © RapidValue Solutions 7 About RapidValue RapidValue is a global leader in providing digital product engineering solutions including Mobility, Cloud, Omni-channel, IoT and RPA to enterprises worldwide. RapidValue offers its digital services to the world’s top brands, Fortune 1000 companies, and innovative emerging start-ups. With offices in the United States, the United Kingdom, Germany, and India and operations spread across the Middle-East, Europe, and Canada, RapidValue delivers enterprise service and solutions across various industry verticals. Disclaimer: This document contains information that is confidential and proprietary to RapidValue Solutions Inc. No part of it may be used, circulated, quoted, or reproduced for distribution outside RapidValue. If you are not the intended recipient of this report, you are hereby notified that the use, circulation, quoting, or reproducing of this report is strictly prohibited and may be unlawful. © RapidValue Solutions www.rapidvaluesolutions.com/blog www.rapidvaluesolutions.com +1 877.643.1850 [email protected]