0Pricing
Micro Frontends Architecture with Module Federation · บทเรียน

การจัดการการนำทางแบบซ้อนและข้ามแอป

เรียนรู้การประสานเส้นทางแบบซ้อนที่ไมโครฟรอนต์เอนด์แต่ละตัวเป็นเจ้าของ และการนำทางจาก MFE หนึ่งไปยังอีก MFE หนึ่งได้อย่างราบรื่น

การจัดการการนำทางแบบซ้อนและข้ามแอป เป็นบทเรียน Micro Frontends Architecture with Module Federation ฟรีบน CoddyKit นี่คือบทเรียนที่ 4 จากทั้งหมด 4 บทเรียน คุณสามารถอ่านบทเรียนทั้งหมดด้านล่างฟรี — จากนั้นลองปฏิบัติด้วยตัวคุณเองในเบราว์เซอร์พร้อมตัวแก้ไขโค้ดในตัวและติวเตอร์ AI ตลอด 24/7 บทเรียนนี้เป็นส่วนหนึ่งของเส้นทางการเรียน 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 ตลอด 24/7) และปลดล็อคส่วนที่เหลือของคอร์ส Micro Frontends Architecture with Module Federation ให้อัปเกรดเป็น CoddyKit PRO คอร์ส Micro Frontends Architecture with Module Federation มีบทเรียนทั้งหมด 4 บทเรียน

คุณจะเรียนรู้อะไรในบทเรียน “การจัดการการนำทางแบบซ้อนและข้ามแอป”

เรียนรู้การประสานเส้นทางแบบซ้อนที่ไมโครฟรอนต์เอนด์แต่ละตัวเป็นเจ้าของ และการนำทางจาก MFE หนึ่งไปยังอีก MFE หนึ่งได้อย่างราบรื่น คุณปฏิบัติ Micro Frontends Architecture with Module Federation ด้วยโค้ดที่ใช้งานได้จริงที่คุณเรียกใช้โดยตรงในเบราว์เซอร์ และติวเตอร์ AI ตลอด 24/7 ตอบคำถามของคุณขณะที่คุณไปผ่านบทเรียน

คุณต้องมีประสบการณ์ก่อนที่จะเริ่มเรียน Micro Frontends Architecture with Module Federation หรือไม่

ไม่จำเป็นต้องมีประสบการณ์มาก่อน Micro Frontends Architecture with Module Federation บน CoddyKit ออกแบบมาสำหรับผู้เริ่มต้นไปจนถึงผู้เรียนขั้นสูง คุณสามารถเริ่มต้นที่นี่หรือเริ่มจากตัวแรกและเรียนด้วยความเร็วของคุณเอง นี่คือบทเรียนที่ 4 จากทั้งหมด 4 บทเรียน

บทเรียน “การจัดการการนำทางแบบซ้อนและข้ามแอป” ใช้เวลานานแค่ไหน

บทเรียน CoddyKit ส่วนใหญ่ใช้เวลาประมาณ 5–10 นาที แต่ละบทเรียนจึงสั้นและเป็นแบบโต้ตอบ คุณสามารถก้าวหน้าอย่างต่อเนื่องและกลับมาเรียนต่อจากตรงที่เพิ่งหยุดบนเว็บและแอปได้เลย

ฉันเขียนและรันโค้ดในบทเรียน Micro Frontends Architecture with Module Federation นี้ได้ไหม

ได้ บทเรียน Micro Frontends Architecture with Module Federation ทุกบทมีตัวแก้ไขโค้ดในตัว คุณจึงเขียนและรันโค้ดจริงได้เลยในเบราว์เซอร์ และได้รับข้อเสนอแนะจาก AI ในทันที — ไม่ต้องติดตั้งในเครื่องของคุณ

บทเรียนทั้งหมดในหลักสูตรนี้

  1. กลยุทธ์การกำหนดเส้นทางแบบรวมศูนย์
  2. การสร้างเส้นทางแบบสหพันธ์
  3. การลิงก์เชิงลึกและการจัดการ URL
  4. การจัดการการนำทางแบบซ้อนและข้ามแอป
← กลับไปที่ Micro Frontends Architecture with Module Federation