How to Build Your Own Micro-Frontend App with Single-SPA and React

How to Build Your Own Micro-Frontend App with Single-SPA and React

Learn how to build your own micro-frontend app from scratch using the single-spa framework and React. Micro-frontends are the future of front end web development. Depending on the micro-frontend framework you choose, you can even have multiple micro-frontend apps — written in React, Angular, Vue, or anything else — coexisting peacefully together in the same larger app.

There’s been a lot of debate over the past couple years around microservices. As a result of this debate, all now know the pros and cons surrounding this concept, as well as the consequences of blindly adopting it for every single project.

Well, the same debate exists for micro-frontends. The term itself says a lot: it gives you the ability to break your frontend into smaller pieces that make sense. This will allow you to test, build, develop, and deploy those pieces faster, since they’re independent.

This term first entered the public lexicon in the famous ThoughtWorks Tech Radar in 2016. This extended the concept from the backend to the frontend.

Today, there’s plenty of frontend developers working on the same projects, or projects that must integrate at some point. Ultimately, developers want to be able to use frameworks or libraries that allow you to build a whole application with lots of pieces (components) built by different people.

Rather than components, we have entire applications integrating like pieces of a puzzle.

You can read more on micro-frontends here. For this article, however, we’ll focus on the practical side. In other words, we’ll cover how to create your first micro-fronted app from scratch using single-spa and React.

Single-spa is a JavaScript router for frontend microservices (that’s another common term they’re known by).

It simplifies the construction of your micro-frontends by allowing the integration of multiple applications built on top of all types of frameworks (Vue, Angular, React, plain HTML/JS/CSS, etc.). Let’s take a closer look!

The app we’ll build

By the end of this article, you’ll be able to build your micro-frontend apps, following up closely the steps presented here.

This is the application we’ll build:

A completed micro-frontend application built with single-spa and React.

Micro-frontend application.

Note that we’ve highlighted the screen into sections — each one corresponds to a different application.

  • App header + menus: those will be managed by the logrocket-single-spa-navbar application
  • Home’s body: managed by the logrocket-single-spa-homepage app
  • About Us page: managed by the logrocket-single-spa-aboutpage app
  • Contact page: managed by the logrocket-single-spa-contactpage app

This is a great example to explore the way the framework deals with the integration of many apps into a single app.

The footer of the page won’t change, so we’ll leave it for the root application.

react web-development javascript programming developer

Bootstrap 5 Complete Course with Examples

Bootstrap 5 Tutorial - Bootstrap 5 Crash Course for Beginners

Nest.JS Tutorial for Beginners

Hello Vue 3: A First Look at Vue 3 and the Composition API

Building a simple Applications with Vue 3

Deno Crash Course: Explore Deno and Create a full REST API with Deno

How to Build a Real-time Chat App with Deno and WebSockets

Convert HTML to Markdown Online

HTML entity encoder decoder Online

How native is React Native? | React Native vs Native App Development

Article covers: How native is react native?, React Native vs (Ionic, Cordova), Similarities and difference between React Native and Native App Development.

How To Write Better Code As A Web Developer - React

Look at three different React code examples from a beginner, intermediate, and advanced web developer. How senior developers think. How to use React state properly. How to use React useEffect properly. What to think about when programming. The differences between senior and junior developers

How to Become A React JavaScript Developer 🚀

Today Qazi & Sonny will be showing you How To Become a React JavaScript Developer 🚀👨‍💻

Hire Dedicated React Native Developer

Have you ever thought of having your own app that runs smoothly over multiple platforms? React Native is an open-source cross-platform mobile application framework which is a great option to create mobile apps for both Android and iOS. **[Hire...

Top 10 Web Development Trends in 2020 | Web Development Skills

Top 10 Web Development Trends in 2020 will provide you with a detailed list of the trends which are currently being noticed. Upskilling to these trends will help you in landing onto better jobs in 2020-2021.