Building a Scalable Web Application with Single-SPA and Microfrontends
At a certain scale, a monolithic frontend becomes a bottleneck. Teams step on each other. Deployments are all-or-nothing. One team's broken code blocks ev...
11 Aug 2024 · 2 min read

At a certain scale, a monolithic frontend becomes a bottleneck. Teams step on each other. Deployments are all-or-nothing. One team's broken code blocks everyone else's release.
Microfrontends solve this the same way microservices solved it on the backend: break the monolith into independently deployable pieces. Single-SPA is one of the frameworks that makes this architecture work.
What Single-SPA Does
Single-SPA lets you compose multiple independent SPAs into one application. Each microfrontend can be developed, tested, and deployed on its own.
Why it works:
- Independent deployments: One team ships without waiting for others.
- Framework agnostic: Mix React, Vue, and Angular in the same shell. Each team picks what they know best.
- Scalable team structure: Each microfrontend maps to a team boundary. Ownership is clear.
Why it hurts:
- Complexity: Shared dependencies, routing coordination, and cross-app communication add overhead.
- Bundle size: Multiple frameworks means duplicate runtime code unless you're careful with shared dependencies.
- Debugging: Tracing a bug across microfrontend boundaries is harder than in a monolith.
The Architecture
Microfrontends follow the same idea as backend microservices. Each one owns a feature or section of the application. A root configuration ties them together.
In the project I built, the structure looks like this:
- root-config: The shell app. Handles routing and loading of microfrontends.
- styleguide: Shared design tokens and reusable components.
- navbar: Owns the navigation bar.
- utilities: Shared utility functions and services.
- procurement: Domain-specific functionality for procurement workflows.
Managing It All With a Script
Local development with multiple microfrontends running simultaneously needs automation. I wrote a Bash script that:
- Kills any processes on ports 9000–9010 to prevent conflicts
- Installs dependencies for each microfrontend using pnpm
- Starts each service in the background
- Prints the URL to access the composed application
Without this kind of automation, you'd spend half your day starting and restarting services.
Here's the repo: https://github.com/ehsangazar/singlespa
When to Use Microfrontends
Use them when: You have multiple teams working on a large frontend. Deployment independence is worth the architectural complexity. You need to migrate incrementally from a legacy app.
Skip them when: You're a small team. You have a single product with a single deployment cadence. The coordination overhead will slow you down more than the monolith does.
Microfrontends are a scaling solution. Apply them at scale.
Ehsan Gazar helps software engineers take LLM and agent systems from demo to production. He writes about building LLM systems that hold up in production: evals, tracing, RAG, agent architecture and cost control. He teaches the Senior to Staff AI Engineer cohort on Maven, where engineers learn to design and defend these systems.
Forward Deployed AI Engineering: From Customer Problem to Production Value
A live Maven cohort for engineers: 10 live 90-minute sessions taking one AI engagement from customer problem to production, ending with eight artefacts and a working slice in your own repo.
January cohort starts Tue 12 Jan 2027, Tue & Thu 6:30pm London. Enrolling now, 20 seats, $1,800.
View the live cohortKeep reading
- React 19 Performance Secrets, Concurrent Rendering, Suspense & Real Tips
- Lazy Loading in HTML and CSS: Enhancing Performance and User Experience
- Edge Rendering with Next.js and Cloudflare Workers
- Rolling Out an Internal UI Component Library
- What is a Design System According to Atlassian?
- CSS Houdini: New Possibilities for Your CSS