Course contentsShow
← React
Lesson 1833 of 2,39643. RoutingFree lesson

Outlet: Rendering Child Routes

Using the Outlet component to define where child route components should render within parent layouts.

What You'll Learn

You'll learn how to use the Outlet component to control exactly where nested child routes appear within a parent route's layout.

The Missing Piece in Your Layout

You've defined a route tree with parent and child routes, but there's a crucial question: where do the child components actually render inside the parent? Without explicitly telling React Router where to display them, nothing appears.

This is where Outlet comes in.

Think of Outlet as a Placeholder

Imagine you're designing a picture frame (the parent route layout) that will hold different photos (child routes). You need to cut out a space in the frame where each photo will go. Outlet is that cutout—it marks the exact spot where React Router should inject the currently matched child route's component.

How It Works

In your parent route component, you import Outlet from React Router and place it wherever you want child content to appear:

import { Outlet } from 'react-router-dom';

function DashboardLayout() {
  return (
    <div>
      <header>Dashboard Header</header>
      <nav>Sidebar Navigation</nav>
      <main>
        <Outlet /> {/* Child routes render here */}
      </main>
      <footer>Dashboard Footer</footer>
    </div>
  );
}

When the user navigates to /dashboard/profile, React Router renders DashboardLayout and replaces the <Outlet /> with the Profile component. Navigate to /dashboard/settings? Same layout, but Settings replaces the outlet content.

The Power of Shared Layouts

Outlet lets you wrap multiple child routes in consistent UI—headers, sidebars, footers—without duplicating code. The parent defines the structure once; children just fill in the variable content area.

Key Takeaway: Outlet is React Router's way of saying "render the active child route component right here" inside a parent layout, enabling reusable, nested layouts without duplication.