Gestire la navigazione annidata e tra app
Impari a coordinare le route annidate gestite dai singoli micro frontend e a navigare senza interruzioni da un MFE all’altro.
Gestire la navigazione annidata e tra app è una lezione Micro Frontends Architecture with Module Federation gratuita su CoddyKit. Questa è la lezione 4 di 4. Puoi leggere la lezione completa qui gratuitamente — poi esercitati direttamente nel browser con un editor di codice integrato e un tutor IA disponibile 24/7. Fa parte del percorso di apprendimento Micro Frontends Architecture with Module Federation, e i tuoi progressi si sincronizzano tra il web e l'app CoddyKit. Il corso Micro Frontends Architecture with Module Federation include 4 lezioni in totale.
Parti di questa lezione non sono ancora state tradotte e vengono mostrate in inglese.
The Nested Routing Challenge
In federated apps, the shell owns top-level routes while each micro frontend owns its own internal (nested) routes. Coordinating the two is the heart of MFE navigation.
Route Ownership
A clear rule helps: the shell maps a route prefix to an MFE, and everything below that prefix belongs to the MFE.
/products/* -> product MFE
/cart/* -> cart MFE
/account/* -> account MFEMounting an MFE at a Prefix
The shell renders the MFE for a prefix and lets it handle the remaining path segment.
<Route path="/products/*" element={<ProductApp />} />Nested Routes Inside an MFE
The MFE defines its own router scoped to its prefix, so it controls its sub-pages without the shell knowing about them.
<Routes>
<Route path="/" element={<List />} />
<Route path=":id" element={<Detail />} />
</Routes>basename for Scoped Routers
Give the MFE router a basename matching its prefix so its links resolve correctly within the larger app.
<BrowserRouter basename="/products">
...
</BrowserRouter>Cross-App Navigation
Sometimes one MFE must send the user into another (e.g. cart linking to checkout). The challenge: it should not import the other MFE router directly.
Navigating via the URL
The cleanest cross-app navigation just changes the URL. The shell router then mounts the right MFE — no direct coupling needed.
history.pushState({}, "", "/checkout");
window.dispatchEvent(new PopStateEvent("popstate"));A Shared Navigation Service
To avoid manual history hacks, the shell can expose a small navigate function that MFEs call, centralizing navigation logic.
import { navigate } from "shell/navigation";
navigate("/checkout");Keeping Routers in Sync
All MFEs must respond to the same browser history. Using one history source (the browser History API) keeps the shell and every MFE router synchronized on back/forward.
Avoiding Route Conflicts
Two MFEs claiming overlapping prefixes cause unpredictable rendering. Maintain a single registry of route prefixes to guarantee they never collide.
Lazy Loading per Route
Combine nested routing with lazy loading: only fetch an MFE bundle when the user navigates to its prefix, keeping initial load small.
const ProductApp = React.lazy(() => import("products/App"));Quick Check
Test your nested-routing knowledge.
Recap
You learned nested and cross-app navigation:
- Shell owns prefixes; MFEs own nested routes
- Use
basenameto scope MFE routers - Navigate across apps via URL or a shared service
- Share one browser history source
- Prevent prefix conflicts and lazy-load by route
Coordinated routing makes federated navigation feel seamless.
Domande Frequenti
La lezione «Gestire la navigazione annidata e tra app» è gratuita?
Sì — il testo completo di «Gestire la navigazione annidata e tra app» è gratuito qui sul web. Per esercitarvi in modo interattivo (un editor di codice integrato e un tutor IA 24/7) e sbloccare il resto del corso Micro Frontends Architecture with Module Federation, passa a CoddyKit PRO. Il corso Micro Frontends Architecture with Module Federation include 4 lezioni in totale.
Cosa imparerò in «Gestire la navigazione annidata e tra app»?
Impari a coordinare le route annidate gestite dai singoli micro frontend e a navigare senza interruzioni da un MFE all’altro. Eserciti Micro Frontends Architecture with Module Federation con codice pratico che esegui direttamente nel browser, e un tutor IA 24/7 risponde alle tue domande mentre lavori sulla lezione.
Ho bisogno di esperienza per iniziare Micro Frontends Architecture with Module Federation?
Non è richiesta alcuna esperienza precedente. Micro Frontends Architecture with Module Federation su CoddyKit è strutturato per principianti e studenti avanzati, quindi puoi iniziare da qui o dall'inizio e procedere al tuo ritmo. Questa è la lezione 4 di 4.
Quanto tempo richiede la lezione «Gestire la navigazione annidata e tra app»?
La maggior parte delle lezioni CoddyKit richiede circa 5–10 minuti. Ogni lezione è breve e interattiva, quindi fai progressi costanti e riprendi esattamente da dove hai lasciato su web e app.
Posso scrivere ed eseguire codice in questa lezione Micro Frontends Architecture with Module Federation?
Sì. Ogni lezione Micro Frontends Architecture with Module Federation include un editor di codice integrato, quindi scrivi ed esegui codice reale direttamente nel tuo browser e ricevi feedback istantaneo dall'IA — nessuna configurazione locale necessaria.
Tutte le lezioni di questo corso
- Strategia di routing centralizzato
- Implementazione del routing federato
- Deep linking e gestione degli URL
- Gestire la navigazione annidata e tra app