Skip to content

Commit 8a5b9ac

Browse files
committed
chore: migrate from pages routing
1 parent 88dc540 commit 8a5b9ac

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+5615
-627
lines changed

package-lock.json

Lines changed: 3940 additions & 334 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,21 @@
99
"lint": "next lint"
1010
},
1111
"dependencies": {
12+
"fast-xml-parser": "^5.0.1",
13+
"html-to-text": "^9.0.5",
14+
"next": "15.1.7",
1215
"react": "^19.0.0",
13-
"react-dom": "^19.0.0",
14-
"next": "15.1.7"
16+
"react-dom": "^19.0.0"
1517
},
1618
"devDependencies": {
17-
"typescript": "^5",
19+
"@eslint/eslintrc": "^3",
20+
"@types/html-to-text": "^9.0.4",
1821
"@types/node": "^20",
1922
"@types/react": "^19",
2023
"@types/react-dom": "^19",
2124
"eslint": "^9",
2225
"eslint-config-next": "15.1.7",
23-
"@eslint/eslintrc": "^3"
26+
"sass": "^1.85.0",
27+
"typescript": "^5"
2428
}
2529
}

public/file.svg

Lines changed: 0 additions & 1 deletion
This file was deleted.

public/globe.svg

Lines changed: 0 additions & 1 deletion
This file was deleted.

public/next.svg

Lines changed: 0 additions & 1 deletion
This file was deleted.

public/vercel.svg

Lines changed: 0 additions & 1 deletion
This file was deleted.

public/window.svg

Lines changed: 0 additions & 1 deletion
This file was deleted.
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
---
2+
title: Micro Frontends In A Nutshell
3+
author: mdworld
4+
publishedAt: 2025-01-01
5+
---
6+
7+
You may have heard of a Micro Frontends recently and felt it a bit difficult to grasp what exactly it is and if it is something you should get involved in. I'll try to give a summary of the what, why, how, and when of the current state. To provide a high-over summary, I'll also add some recommended reading if you would like to get more details.
8+
9+
## _Why_ use Micro Frontends?
10+
11+
Do you have a very large front-end code-base?
12+
13+
And by large, I'm talking about 50+ developers in a dozen of teams or more, probably cross-department, working on the same code-base in some manner.
14+
Do you have enterprise-scale continuous integration with e.g. GitLab, Bamboo running so many pipelines that the bottleneck is no longer a matter of adding more pods?
15+
Do you employ configuration managers or an Ops department to make sure deployments won't affect each other too much?
16+
Do you have considerable codebases in incompatible front-end stacks, e.g. because of a migration from AngularJS to Angular >2?
17+
18+
Then chances are you need to use Micro Frontends. Or actually, you most probably are _already_ using Micro Frontends.
19+
20+
## _What_ are Micro Frontends?
21+
22+
How is it possible you would not know you are using Micro Frontends? And why are we just now hearing so much about them? The truth is that although the term is relatively new it actually covers **any range of solutions to integrate a collection of smaller frontends into one application**.
23+
24+
Similar to Micro Service architectures, Micro Frontends facilitate large codebases by breaking them up into manageable pieces. This means:
25+
26+
- Technological stack across Micro Frontends in the same application may differ
27+
- A Micro Frontend has a clear and concise purpose, following the SOLID principles
28+
- Teams of developers maintain one or more Micro Frontend that are isolated in runtime from the rest of the code
29+
30+
The term is now popularized because of the advent of _Module Federation_ in Webpack 5. Webpack 5 has been released towards the end of 2020, but this new major release is taking some time to be integrated in relevant tooling, e.g. Nx and Ng CLI.
31+
32+
Note that Micro Frontends (MFEs) are sometimes also referred to as _Micro Apps_.
33+
34+
## _How_ do you build Micro Frontends?
35+
36+
Since Micro Frontends as a concept are not new, some solutions that can be classified as Micro Frontends are ancient, considering the speed of development in the frontend ecosystem. Here are some of them, to give an idea of how broad Micro Frontends can be interpreted:
37+
38+
- Run several frontend applications on different URLs and cross refer them with plain **hyperlinks**
39+
- Run several frontend applications on different URLs on the same page in **iframes**
40+
- Develop frontend components in separate teams and integrate them at build time to be deployed as a **deployment monolith**
41+
- Use macro **Web Components** as an abstraction layer for components
42+
- Develop frontend components in separate teams and integrate them at runtime with **Module Federation**
43+
44+
I won't go into all the details about the pros and cons of each of these solutions. Instead I refer you to the recommended reading list below.
45+
46+
Note that solutions can be combined: you can have a deployment monolith (that expects components that are all using the same stack) but wrap components in Web Components to provide an abstraction layer and use different stacks to produce the Web Components. Additionally, you can use Web Components in combination with Module Federation for instance if you are migrating towards Module Federation as a Micro Frontends solution.
47+
Consider this schematic representation of a web application:
48+
49+
<Lightbox imgPath="/lightbox/mfe/page.svg" imgTitle="Overview of a page" />
50+
51+
This could be implemented with different platforms like Angular and React by wrapping them in Web Components:
52+
53+
<Lightbox imgPath="/lightbox/mfe/web-components.svg" imgTitle="Web Components" />
54+
55+
Module Federation is the newest solution and many libraries are still adapting to it. Last year, Nx 12 released with support for Webpack 5 and Module Federation. See a real working example here https://code-star.github.io/nx-reference-shell/ or its source in https://github.com/code-star/nx-reference.
56+
57+
Because Micro Frontends break up a codebase into smaller, more manageable fragments, they are often mentioned in combination with Monorepo solutions like Nx or yarn/npm workspaces. However, it is perfectly possible to implement Micro Frontends without monorepos!
58+
59+
## _When_ to use Micro Frontends?
60+
61+
New technology inspires developers to experiment, but Micro Frontends and with that Module Federation are not worth the upkeep for small to medium applications. All-in solutions like Next or Gatsby are great fits for smaller applications and custom Angular applications, when well organized, scale very well up to enterprise level.
62+
63+
However, no framework inherently supports older versions of itself. So if a big bang migration from AngularJS to Angular or any other framework for that matter, you'll end up with some kind of Micro Frontends solution. Plenty of enterprise codebases currently use some combination of hyperlinks and deployment monoliths.
64+
65+
This could look like a bank that offers a set of public pages (e.g. the general home page, and the landing pages of its departments) referencing each other with hyperlinks and a protected monolith app with many components (e.g. checking account, subscriptions to bank products, investments on one page).
66+
67+
<Lightbox imgPath="/lightbox/mfe/hyperlinks-and-monolith.svg" imgTitle="Hyperlinks and Monolith" />
68+
69+
Exploring Module Federation can be worth it if continuous integration is slowed down too much because of the large amounts of tests and compilation of all the involved components. But note that there are other approaches, such as using Nx monorepos with properly set up hierarchy and running only affected tests.
70+
71+
Another reason to use Module Federation can be the need to support multiple frameworks. Compared to Web Components, Module Federation improves the runtime isolation of components while simultaneously reducing isolation of shared dependencies to reduce the overall footprint of the application.
72+
73+
Compare to the diagram for the earlier example using macro Web Components, you can see that lodash, Angular and React are only loaded once, despite being used by multiple isolated components:
74+
75+
<Lightbox imgPath="/lightbox/mfe/module-federation.svg" imgTitle="Module Federation" />
76+
77+
## Want to know more?
78+
79+
If you want to know more about Micro Frontends, Module Federation or Monorepos, you can contact met at [@mdworldNL](https://twitter.com/mdworldNL) on Twitter. We have experience with enterprise frontend at all the major banks and many governmental departments in the Netherlands.
80+
81+
When you want more background information as a developer, you can also read the articles provided below.
82+
83+
## Recommended in-depth reading
84+
85+
- Introduction to Micro Frontends: https://micro-frontends.org/
86+
- Introduction to Micro Frontends: https://martinfowler.com/articles/micro-frontends.html
87+
- Angular Architects
88+
- Micro Frontends introduction: https://www.angulararchitects.io/en/aktuelles/a-software-architects-approach-towards/
89+
- Micro Frontends series: https://www.angulararchitects.io/en/aktuelles/micro-apps-with-web-components-using-angular-elements/
90+
- Module Federation series: https://www.angulararchitects.io/en/aktuelles/the-microfrontend-revolution-module-federation-in-webpack-5/
91+
- By my colleague Peter Eijgermans:
92+
- Micro Frontends by Example: https://dzone.com/articles/micro-frontends-by-example-8
93+
- (Video) Micro Frontends: The What, the Why and the How by Peter Eijgermans https://youtu.be/TWcoziCdPkE
94+
95+
This article was originally published at https://mdworld.nl/micro-frontends-in-a-nutshell

src/app/articles/layout.tsx

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import { PropsWithChildren } from "react";
2+
3+
export default function MdxLayout({ children }: PropsWithChildren) {
4+
// Create any shared layout or styles here
5+
return (
6+
<div style={{ color: "blue", border: "10px dotted red" }}>
7+
foo{children}
8+
</div>
9+
);
10+
}

src/app/favicon.ico

315 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)