Capítulo 45 de 57
The <Outlet /> component marks where a route's matching child route should render, enabling nested routing layouts; if a route has no component defined, an <Outlet /> is rendered automatically.
<Outlet />: Renders the next potentially matching child route. Takes no props and can be placed anywhere in a route's component tree.component option is left undefined, TanStack Router renders an <Outlet /> for it automatically.<Outlet /> renders null rather than erroring.<Outlet /> so all top-level routes render inside it.import { createRootRoute, Outlet } from '@tanstack/react-router'
export const Route = createRootRoute({
component: RootComponent,
})
function RootComponent() {
return (
<div>
<h1>My App</h1>
<Outlet /> {/* This is where child routes will render */}
</div>
)
}
<Outlet /> in the root route to provide a persistent layout wrapping all nested routes.<Outlet /> is the mechanism that makes nested routing/layouts possible in TanStack Router.component on a route is a valid shortcut for pass-through layout routes, it implicitly renders an outlet.<Outlet /> anywhere in the component tree, not just at the top, to control exactly where nested content appears.<Outlet />.<Outlet /> to render their children.