dioxus_router/hooks/
use_router.rs

1use crate::{prelude::RouterContext, utils::use_router_internal::use_router_internal};
2
3#[deprecated = "prefer the `router()` function or `use_route` functions"]
4#[must_use]
5/// A hook that provides access to information about the router.
6pub fn use_router() -> RouterContext {
7    use_router_internal().expect("use_route must have access to a router")
8}
9
10/// Acquire the router without subscribing to updates.
11#[doc(alias = "url")]
12pub fn router() -> RouterContext {
13    dioxus_lib::prelude::consume_context()
14}
15
16/// Try to acquire the router without subscribing to updates.
17#[doc(alias = "url")]
18pub fn try_router() -> Option<RouterContext> {
19    dioxus_lib::prelude::try_consume_context()
20}