0Pricing
Micro Frontends Architecture with Module Federation · 강의

중앙 집중식 라우팅 전략

하나의 호스트 애플리케이션이 통합된 모든 마이크로 프런트엔드의 라우팅을 관리하는 방식을 이해합니다.

중앙 집중식 라우팅 전략은(는) CoddyKit의 무료 Micro Frontends Architecture with Module Federation 강의입니다. 이것은 4개 중 1번째 강의입니다. 아래에서 전체 강의를 무료로 읽을 수 있으며, 내장 코드 에디터와 24/7 AI 튜터와 함께 브라우저에서 직접 실습할 수 있습니다. 이 강의는 Micro Frontends Architecture with Module Federation 학습 경로의 일부이며, 진행 상황이 웹과 CoddyKit 앱에 동기화됩니다. Micro Frontends Architecture with Module Federation 강의에는 총 4개의 강의가 포함되어 있습니다.

이 강의의 일부는 아직 번역되지 않았으며 영어로 표시됩니다.

Intro to Centralized Routing

Welcome to the lesson on Centralized Routing Strategy in Micro Frontends! This approach is crucial for managing navigation across different parts of a large application.

We'll explore how a single 'host' application can take control of all routing decisions, providing a unified user experience.

What is Centralized Routing?

In a centralized routing setup, the main host application (also known as the shell or container) is responsible for defining and managing all routes for the entire application.

  • It acts as the single source of truth for navigation.
  • It decides which Micro Frontend (MFE) component should be loaded for a given URL path.
  • Remote MFEs typically don't manage their own top-level routes.

The Host's Routing Role

Imagine your host application as a traffic controller. When a user navigates to a URL, the host intercepts it, looks at its routing table, and then directs the request to the appropriate Micro Frontend.

The host often uses a routing library (like React Router for React apps) to define these global routes.

Conceptual Host Router Setup

Here's a simplified look at how a host's routing configuration might appear using a popular routing library. Notice how different paths are mapped to components from various Micro Frontends.

import React from 'react';
import { BrowserRouter as Router, Route, Switch } from 'react-router-dom';

// Imagine these are dynamically loaded MFE components
const ProductMFE = React.lazy(() => import('product_app/ProductPage'));
const CartMFE = React.lazy(() => import('cart_app/CartPage'));
const UserProfileMFE = React.lazy(() => import('user_app/ProfilePage'));

const App = () => (
  <Router>
    <Switch>
      <Route path="/products" component={ProductMFE} />
      <Route path="/cart" component={CartMFE} />
      <Route path="/profile" component={UserProfileMFE} />
      <Route path="/" component={HomePage} exact />
    </Switch>
  </Router>
);

export default App;

Dynamic Loading of MFEs

To efficiently load MFEs, the host typically uses dynamic imports. This means an MFE's code is only fetched and loaded when its corresponding route is activated, not upfront when the main application loads.

This improves initial page load times, as users only download the code they need.

Code: Dynamic MFE Import

This snippet shows how React.lazy() combined with Suspense enables dynamic loading and provides a fallback while the MFE component is being fetched.

import React, { Suspense } from 'react';

// Dynamically import a remote component
const RemoteButton = React.lazy(() => import('remoteApp/Button'));

const HostComponent = () => (
  <div>
    <h1>My Host App</h1>
    <Suspense fallback={<div>Loading Remote Button...</div>}>
      <RemoteButton label="Click Me!" />
    </Suspense>
  </div>
);

export default HostComponent;

Benefits of Centralized Routing

Adopting a centralized routing strategy offers several key advantages:

  • Unified User Experience: Ensures consistent navigation patterns and URLs across the entire application.
  • Simplified Global Navigation: Easier to implement a single, cohesive navigation bar or menu.
  • Host Control: The host maintains full control over which MFEs are loaded and when.
  • Easier Analytics: Centralized routing can simplify tracking user journeys across the entire application.

Considerations and Challenges

While beneficial, centralized routing also has its considerations:

  • Host Dependency: The host becomes a critical dependency; if it fails, the entire routing system is down.
  • Scalability of Routing Logic: A very large application might make the host's routing configuration complex and difficult to manage.
  • MFE Autonomy: Remote MFEs have less control over their own public-facing URLs.
  • Version Management: Changes to routes in the host might require coordination with MFE deployments.

When to Use Centralized Routing

This strategy is often ideal for scenarios where:

  • A single team or entity owns the overall application shell and navigation.
  • The application has a clear hierarchy and a relatively stable set of top-level routes.
  • A consistent look and feel across all MFEs is a high priority.
  • There's a need for tight integration and shared context across different parts of the application.

Routing Strategy Check

Which of the following are key characteristics or benefits of a Centralized Routing Strategy in Micro Frontends?

Centralized Routing Recap

In this lesson, we explored the Centralized Routing Strategy. We learned that the host application controls all top-level routes, dynamically loading Micro Frontends as needed.

This approach offers benefits like a unified user experience and simplified global navigation, though it introduces a strong dependency on the host. Understanding when to apply this strategy is key to effective Micro Frontend architecture.

자주 묻는 질문

“중앙 집중식 라우팅 전략” 강의는 무료인가요?

네 — “중앙 집중식 라우팅 전략” 전체 내용을 이 웹사이트에서 무료로 읽을 수 있습니다. 인터랙티브하게 실습하려면(내장 코드 에디터와 24/7 AI 튜터), CoddyKit PRO로 업그레이드하면 Micro Frontends Architecture with Module Federation 강의 전체를 잠금 해제할 수 있습니다. Micro Frontends Architecture with Module Federation 강의에는 총 4개의 강의가 포함되어 있습니다.

“중앙 집중식 라우팅 전략”에서 뭘 배우나요?

하나의 호스트 애플리케이션이 통합된 모든 마이크로 프런트엔드의 라우팅을 관리하는 방식을 이해합니다. 브라우저에서 직접 실행하는 실습 코드로 Micro Frontends Architecture with Module Federation을(를) 배우며, 24/7 AI 튜터가 강의를 진행하면서 질문에 답변해줍니다.

Micro Frontends Architecture with Module Federation을(를) 시작하는 데 경험이 필요한가요?

사전 경험은 필요하지 않습니다. CoddyKit의 Micro Frontends Architecture with Module Federation은(는) 초급자부터 고급 학습자까지를 위해 구성되어 있으므로, 여기서 시작하거나 처음부터 시작할 수 있으며 자신의 속도대로 진행할 수 있습니다. 이것은 4개 중 1번째 강의입니다.

“중앙 집중식 라우팅 전략” 강의는 얼마나 걸리나요?

대부분의 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(으)로 돌아가기