Slide 1

Slide 1 text

Micro Frontend Routing Michael Egger-Zikes Solutions for mature applications ANGULARarchitects.io

Slide 2

Slide 2 text

Micro Frontend Routing Michael Egger-Zikes Solutions for mature applications ANGULARarchitects.io

Slide 3

Slide 3 text

Micro Frontend Routing Michael Egger-Zikes Solutions for mature applications ANGULARarchitects.io

Slide 4

Slide 4 text

Micro Frontends Different Versions Developer Experience Seamless Integration What this talk is about Different Frameworks Distributed Routing Michael Egger-Zikes (@MikeZks)

Slide 5

Slide 5 text

About Michael • Michael Egger-Zikes ANGULARarchitects.io • Trainings, Consultancy, Reviews • Focus on Angular Remote Workshops: Public & tailored to your company angulararchitects.io/angular-workshops Michael Egger-Zikes (@MikeZks)

Slide 6

Slide 6 text

Why do we need Micro Frontends with Multi Version and Multi Tech support??

Slide 7

Slide 7 text

Micro Frontends: Multi Version/Tech • Separate build and deployment processes • Independent developer teams • Different frontend technologies • Seamless integration? Michael Egger-Zikes (@MikeZks)

Slide 8

Slide 8 text

Micro Frontends: Multi Version/Tech • Should this architecture be your first choice? • Maybe not … Michael Egger-Zikes (@MikeZks)

Slide 9

Slide 9 text

Choose the right approach • Build Monolith • Everything known at build time • Same versions • Apps separated with DDD patterns • Module Federation with same dependency versions • Dynamic cross origin integration possible • Different build- & deployment processes, but same versions • Webpack 5 • Module Federation with different dependency versions • Bootstraping different apps • No shared dependency injection, but shared dependencies possible • Comparable to Web Components and Framework Root Components Michael Egger-Zikes (@MikeZks)

Slide 10

Slide 10 text

How does Routing work in a Multi Version and Multi Tech setup? ?

Slide 11

Slide 11 text

Routing facts • Several bootstrapped apps → different Router instances • Only one address bar → only one URL • Default behavior →URL gets overwritten w/o coordination • Sounds like chaos, right? Michael Egger-Zikes (@MikeZks)

Slide 12

Slide 12 text

DEMO History API

Slide 13

Slide 13 text

History API findings • Routers can not recognize History API pushState changes • No callback possible • Only user interaction can be identified • By using a popstate event listener • Is this good or bad? Michael Egger-Zikes (@MikeZks)

Slide 14

Slide 14 text

Targets for a Routing concept • How many apps need to be active in the shell concurrently? • Do Apps have own demand for changing the Route? • Necessary to manage more than one Route? • Deep Linking between Apps resp. Shell & App? • Are Apps allowed to be nested? Michael Egger-Zikes (@MikeZks)

Slide 15

Slide 15 text

Choosing your challenge • Easy challenge • Intermediate challenge • Tough challenge Michael Egger-Zikes (@MikeZks)

Slide 16

Slide 16 text

Easy challenge • Only one router instance • Coordinates all routing requests • Messaging API to communicate routing requests • Limit access to pushState Michael Egger-Zikes (@MikeZks)

Slide 17

Slide 17 text

Intermediate challenge • Only one MFE active at one time • No nested MFEs • Defined route segments for shell and MFE Michael Egger-Zikes (@MikeZks)

Slide 18

Slide 18 text

Tough challenge • Each MFE is allowed to use routing • Use default framework routing • How do we avoid URL chaos? • Not supported by ... • Module Federation: out of scope • Browser: no API Michael Egger-Zikes (@MikeZks)

Slide 19

Slide 19 text

DEMO URL Chaos

Slide 20

Slide 20 text

Possible solution • Monkey patch pushState & replaceState → React on URL changes → Prevent that certain Apps change the URL • Offer framework-specific Distributed Routing support → Intercept navigation to transform URL and execute App State change → Avoid unknown path errors • Intelligent URL composition → Convert App internal to Shell compatible URL Michael Egger-Zikes (@MikeZks)

Slide 21

Slide 21 text

URL Composition • Single App URLs: • Use the concept of Angular’s named RouterOutlets → But cross App, cross Router https://www.angulararchitects.io/mfe-1/article/search https://www.angulararchitects.io/mfe-2/invoice/edit/8 https://www.angulararchitects.io/(mfe-1:article/search//mfe-2:invoice/edit/8) Michael Egger-Zikes (@MikeZks)

Slide 22

Slide 22 text

No content

Slide 23

Slide 23 text

DEMO URL Composition

Slide 24

Slide 24 text

DEMO Different Frameworks

Slide 25

Slide 25 text

! • Define your requirements • Know, whether you need multi- version and multi-tech support • Know, whether you need to show more than one Micro App at one time • Accept the challenge Key takeaways

Slide 26

Slide 26 text

What is on the Roadmap? Tell me more! ?

Slide 27

Slide 27 text

Complex Routing Big three: Angular, React, Vue Distributed State Management Headless Mode Roadmap Messaging API Michael Egger-Zikes (@MikeZks)

Slide 28

Slide 28 text

[web] ANGULARarchitects.io [twitter] Michael Egger-Zikes (@MikeZks) [npm] @angular-architects/microapp [repo] https://github.com/intauria/microapp Contact | Lib | Source Remote Workshops: Public & tailored to your company angulararchitects.io/angular-workshops