Lazy loading defers loading a component until its route is accessed. In a modular React application, this reduces the initial bundle size while allowing business-domain features to load on demand. section 5.1
A route-level implementation combines:
- React.lazy with dynamic imports to load feature components on demand. section 5.1 section 3.4
- Suspense with a fallback while a requested component loads. section 5.1
Listing 5.1 Modular route application
const CheckoutApp = lazy(() =>
import('../features/checkout/CheckoutApp')); #A
const UserProfileApp = lazy(() =>
import('../features/profile/UserProfileApp'));
const ProductInventoryApp = lazy(
() => import('../features/products/ProductInventoryApp')
);
const ModularRouteApp = () => {
return (
<BrowserRouter>
<Suspense fallback={<div>Loading...</div>}> #B
<nav #C
style={{
display: 'flex',
gap: '10px',
marginBottom: '20px',
}}
>
<Link to="/checkout">Checkout</Link>
<Link to="/profile">Profile</Link>
<Link to="/products">Products</Link>
</nav>
<Routes> #D
<Route path="/" #E
element={<Navigate to="/products" replace />} />
<Route path="/checkout/*" element={<CheckoutApp />} />
<Route path="/profile/*" element={<UserProfileApp />} />
<Route path="/products/*" element={<ProductInventoryApp />} />
<Route path="*" element={<div>404: Page Not Found</div>} /> #F
</Routes>
</Suspense>
</BrowserRouter>
);
};
The example shows lazily imported checkout, profile, and product features, wrapped in Suspense and connected to domain routes. section 5.1











