DEV Community

Cover image for Micro frontends in 1 minute
Seb
Seb

Posted on

Micro frontends in 1 minute

I'm a big fan of reading docs & manuals before I try things especially when they are a bit more complex (advanced). However I know how much joy and motivation it gives when you get first positive experience fast (e.g. running working example). That's why I've decided to look into micro learning where you might scratch the surface, experience if it's for you and get some insights what's next if you want more.

Today I want to give you short introduction to micro frontends architecture starting from project structure setup. Following the words above let's get working example first. I will use real-life example - we will create a banking app consist of micro frontends.

πŸ•’ Time start

First of all let's create an empty (None) NX workspace:

npx create-nx-workspace@latest
Enter fullscreen mode Exit fullscreen mode

and get into it:

cd bank-mfe
Enter fullscreen mode Exit fullscreen mode

Then let's add some framework to the NX workspace:

nx add @nx/angular
Enter fullscreen mode Exit fullscreen mode

Now let's create apps folder to store all our micro frontends:

mkdir apps
Enter fullscreen mode Exit fullscreen mode

and get into it:

cd apps
Enter fullscreen mode Exit fullscreen mode

It's time to create our micro frontends:

nx g @nx/angular:host shell --remotes=account,payment,investment,mortgage,pension
Enter fullscreen mode Exit fullscreen mode

πŸ•’ Stop the time!

You did it! Your project consist of micro frontends! Now you can start and see it in browser by:

nx serve shell --open
Enter fullscreen mode Exit fullscreen mode

If you actively develop/change given micro frontend remember to serve it with devRemotes like:

nx serve shell --open devRemotes=account
Enter fullscreen mode Exit fullscreen mode

πŸ‘¨β€πŸ’» Link to code example

Code example: https://github.com/sebgos/bank-mfe

Video: https://www.youtube.com/watch?v=Vyi8pjuuky0

I have used:

Curious to get more insights on micro frontends? Let me know in the comments!

Top comments (0)