Micro Frontends Architecture with Module Federation · レッスン

ネストしたナビゲーションとアプリ間ナビゲーション

個々のマイクロフロントエンドが所有するネストしたルートを調整し、あるMFEから別のMFEへシームレスに移動する方法を学びます。

レッスン 4/413 ステップ

「ネストしたナビゲーションとアプリ間ナビゲーション」はCoddyKit上の無料Micro Frontends Architecture with Module Federationレッスンです。 これはレッスン4/4です。 下記で完全なレッスンを無料で読むことができます。その後、ブラウザ内の組み込みコードエディタと24時間対応のAIチューターでハンズオン演習できます。 これはMicro Frontends Architecture with Module Federation学習パスの一部であり、ウェブとCoddyKitアプリ全体で進捗が同期されます。 Micro Frontends Architecture with Module Federationコースには全4レッスンが含まれています。

このレッスンの一部はまだ翻訳されておらず、英語で表示されています。

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 MFE

Mounting 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 basename to 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.

無料で開始

AI チューターと学ぶ JavaScript — 無料

ブラウザでリアルコードを書いて実行し、24/7 の AI チューターから瞬時にサポートを受け、ウェブまたはアプリで続きから学習できます。

コース
12
レッスン
48

よくある質問

「ネストしたナビゲーションとアプリ間ナビゲーション」レッスンは無料ですか?

はい。「ネストしたナビゲーションとアプリ間ナビゲーション」の完全なテキストはこのウェブで無料で読めます。インタラクティブに演習し(組み込みコードエディタと24時間対応のAIチューター)、Micro Frontends Architecture with Module Federationコースの残りをアンロックするには、CoddyKit PROにアップグレードしてください。 Micro Frontends Architecture with Module Federationコースには全4レッスンが含まれています。

「ネストしたナビゲーションとアプリ間ナビゲーション」で何を学びますか?

個々のマイクロフロントエンドが所有するネストしたルートを調整し、あるMFEから別のMFEへシームレスに移動する方法を学びます。 ブラウザで直接実行するハンズオンコードでMicro Frontends Architecture with Module Federationを演習し、24時間対応のAIチューターがレッスンを進める中での質問に答えます。

Micro Frontends Architecture with Module Federationを始めるのに経験は必要ですか?

事前経験は必要ありません。CoddyKitのMicro Frontends Architecture with Module Federationは初級者から上級者向けに構成されているため、ここから始めるか最初から始めて、自分のペースで進むことができます。 これはレッスン4/4です。

「ネストしたナビゲーションとアプリ間ナビゲーション」レッスンにはどのくらい時間がかかりますか?

ほとんどのCoddyKitレッスンは約5~10分かかります。各レッスンはコンパクトでインタラクティブなので、着実に進歩し、ウェブとアプリ全体で正確に前回の場所から再開できます。

このMicro Frontends Architecture with Module Federationレッスンでコードを書いて実行できますか?

はい。すべてのMicro Frontends Architecture with Module Federationレッスンに組み込みコードエディタが含まれているため、ブラウザでリアルコードを書いて実行し、即座のAIフィードバックを取得できます。ローカル設定は不要です。

このコースのすべてのレッスン

  1. 集中型ルーティング戦略
  2. Federatedルーティングの実装
  3. ディープリンクとURL管理
  4. ネストしたナビゲーションとアプリ間ナビゲーション
← Micro Frontends Architecture with Module Federationに戻る