{"record":{"id":"983341757d40e87d","repo":"leptos-rs/leptos","slug":"outlet-used-without-routecontext-being-provided","errorCode":null,"errorMessage":"<Outlet/> used without RouteContext being provided.","messagePattern":"<Outlet/> used without RouteContext being provided\\.","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"router/src/nested_router.rs","lineNumber":1102,"sourceCode":"        provide_context(child.clone());\n        let outer_owner = outer_owner.clone();\n        (move || {\n            trigger.track();\n            let mut view_fn = view_fn.lock().or_poisoned();\n            view_fn(outer_owner.child())\n        })\n        .into_any()\n    })\n}\n\n/// Displays the child route nested in a parent route, allowing you to control exactly where\n/// that child route is displayed. Renders nothing if there is no nested child.\n#[component]\npub fn Outlet() -> impl RenderHtml\nwhere\n{\n    let ChildRoute(child) = use_context()\n        .expect(\"<Outlet/> used without RouteContext being provided.\");\n    let child = child.lock().or_poisoned().clone();\n    let outer_owner = Owner::current().unwrap();\n    child.map(|child| {\n        move || {\n            child.trigger.track();\n            let mut view_fn = child.view_fn.lock().or_poisoned();\n            view_fn(outer_owner.child())\n        }\n    })\n}\n","sourceCodeStart":1084,"sourceCodeEnd":1113,"githubUrl":"https://github.com/leptos-rs/leptos/blob/32d20f6c9d517451d77beb68d88c7716823dac41/router/src/nested_router.rs#L1084-L1113","documentation":"`<Outlet/>` reads the `ChildRoute` context that the router provides to each matched route so the outlet can render the next nested child. When no `RouteContext` is in scope (outlet used outside a route's view, or a route with no children rendered where none exist), the `expect` panics with this message.","triggerScenarios":"Rendering `<Outlet/>` outside any route view (e.g. directly in a page above `<Routes>`); using `<Outlet/>` in a leaf route with no nested children configured; a component like `LoggedInContent` rendered outside the `<ParentRoute>`/`<Route>` tree.","commonSituations":"Layout components meant to nest children but placed outside the parent route definition; forgetting to wrap child routes in `<ParentRoute>` so the outlet context is provided; tests rendering `<Outlet>` standalone.","solutions":["Render `<Outlet/>` only inside a route view, and ensure child routes are declared as `<ParentRoute>` (or nested `<Route>` children) so the outlet context exists.","Check the route hierarchy: the component containing `<Outlet/>` must be the `view` of a parent route that has child routes.","If children may be absent, wrap the outlet in a component that is only mounted within a parent route, or conditionally render based on matched children."],"exampleFix":"// before\nview! {\n  <LoggedInContent/> // contains <Outlet/>, but rendered outside routes -> panic\n  <Routes/>\n}\n\n// after\nview! {\n  <Routes>\n    <ParentRoute path=path!(\"/app\") view=LoggedInContent>\n      <Route path=path!(\"/dashboard\") view=Dashboard/>\n    </ParentRoute>\n  </Routes>\n}\n// LoggedInContent renders <Outlet/> inside its view.","handlingStrategy":"fallback","validationCode":"let has_outlet_ctx = use_context::<crate::nested_router::ChildRoute<impl AnyView>>().is_some();\nif !has_outlet_ctx { return ().into_any(); }","typeGuard":"fn outlet_available() -> bool { /* inside a route view */ use_context::<Matched>().is_some() }","tryCatchPattern":null,"preventionTips":["Render <Outlet/> only as part of a parent route's view.","Declare nested children with <ParentRoute> so outlet context is provided.","Structure route trees in tests to verify nested layouts render."],"tags":["router-context","outlet","leptos"],"backgroundTag":"hook-called-outside-router","analyzedSha":"32d20f6c9d517451d77beb68d88c7716823dac41","analyzedAt":"2026-09-01T18:55:42.580Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T01:17:15.007Z"}