useRoute
Description
Use route config without having to create the component with the route builder.
Import
import { useRoute } from "dreamkit";Definition
import type { Route } from "dreamkit";
declare const useRoute: (route: Route) => { setParams: (params: object) => void; params: object;};Examples
Example 1
import { $route, useRoute, s, Link } from "dreamkit";
export const route = $route.params({ id: s.number().optional(),});
export default function User() { const { params } = useRoute(route); return ( <ul> {/* @ts-ignore */} <Link href="/" id={{ id: 1 }}> id: 1 </Link> {/* @ts-ignore */} <Link href="/">id: undefined</Link> <li>id: {params.id}</li> </ul> );}