Components and micro-frontends each serve unique purposes in the development of scalable, maintainable, and efficient web applications.
Components and micro-frontends work at different levels and have different jobs. This document will explain these concepts, showing their special features, uses, and how they work together in making software.
A component is a reusable UI building block. It encapsulates UI, functionality, and styling, reusable across applications.
<Checkbox>
ComponentConsider a checkbox component in a web application. This simple UI element allows users to make a selection, typically a binary choice, and its appearance and behavior can be customized through various properties:
In this example, the checkbox component's properties and behavior are controlled by its parent component or container, illustrating the component's adaptability and encapsulation within different parts of an application.
Micro-frontends extend the concept of microservices to the frontend development realm. A micro-frontend is a self-contained portion of a web application, representing a specific business or domain aspect. It allows teams to develop, test, and deploy parts of the application independently.
Independence: Micro-frontends can be developed, tested, and deployed independently of other parts of the application.
Domain-specific: They are closely aligned with a specific business domain or functionality.
Self-contained: Each micro-frontend is responsible for its own data fetching, processing, and rendering.
The user profile section of a web application, developed as a micro-frontend, serves as a self-contained unit for user information management. Key aspects include:
This micro-frontend operates with autonomy, supported by:
Key highlights of this micro-frontend include:
This example effectively illustrates the micro-frontend architecture's principles, such as:
A component is a technical solution that encapsulates a specific behavior within a frontend element. This behavior can be modified or controlled by a parent component or container, allowing for reusable and encapsulated UI building blocks within the application.
A micro-frontend, in the context of module federation, is a technical representation of a business subdomain. It possesses its own behavior and logic, which are driven and controlled by itself rather than by external entities. This self-contained approach facilitates independent development and deployment, aligning closely with specific business functionalities or domains.