{"record":{"id":"5e3c86443ac878f7","repo":"DioxusLabs/dioxus","slug":"use-route-must-be-called-in-a-descendant-of-a-ro","errorCode":null,"errorMessage":"`use_route` must be called in a descendant of a Router component","messagePattern":"`use_route` must be called in a descendant of a Router component","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/router/src/hooks/use_route.rs","lineNumber":48,"sourceCode":"/// fn Index() -> Element {\n///     let path: Route = use_route();\n///     rsx! {\n///         h2 { \"Current Path\" }\n///         p { \"{path}\" }\n///     }\n/// }\n/// #\n/// # let mut vdom = VirtualDom::new(App);\n/// # vdom.rebuild_in_place();\n/// # assert_eq!(dioxus_ssr::render(&vdom), \"<h1>App</h1><h2>Current Path</h2><p>/</p>\")\n/// ```\n#[doc(alias = \"use_url\")]\n#[must_use]\npub fn use_route<R: Routable + Clone>() -> R {\n    match use_router_internal() {\n        Some(r) => r.current(),\n        None => {\n            panic!(\"`use_route` must be called in a descendant of a Router component\")\n        }\n    }\n}\n","sourceCodeStart":30,"sourceCodeEnd":52,"githubUrl":"https://github.com/DioxusLabs/dioxus/blob/24f6a829df0dfa203961a98ea4cae21c2ff27e28/packages/router/src/hooks/use_route.rs#L30-L52","documentation":"use_route called use_router_internal() and received None, meaning the component is not a descendant of a Router component. The hook cannot resolve the current route without router context, so it panics immediately.","triggerScenarios":"Thrown at packages/router/src/hooks/use_route.rs:48 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Call use_route only in components that are descendants of a Router component."],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"24f6a829df0dfa203961a98ea4cae21c2ff27e28","analyzedAt":"2026-08-23T07:10:14.078Z","contentChangedAt":"2026-08-23T07:10:14.078Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}