Skip to main content

useOutlet

Returns the element for the child route at this level of the route hierarchy. Used internally by <Outlet> to render child routes.

Signature

Parameters

unknown
Optional context to pass to the outlet. This is typically used with useOutletContext in child routes.

Returns

React.ReactElement | null
The child route element to render, or null if no child routes match.

Usage

Basic usage

This is equivalent to:

Pass context to child routes

Conditional outlet rendering

Animate route transitions

Custom outlet wrapper

Common Patterns

Error boundary wrapper

Loading wrapper

Scroll restoration

Track depth

Custom transition logic

Comparison with Outlet

Use <Outlet> for simple layouts, and useOutlet when you need:
  • Conditional rendering based on outlet existence
  • Custom wrappers around the outlet
  • Animation/transition control
  • Additional processing of the outlet element

Type Safety

Type outlet context