useResolvedPath
useResolvedPath returns an accessor for resolving a path against the current route.
Import
import { useResolvedPath } from "@solidjs/router";Type
function useResolvedPath(path: () => string): () => string | undefined;Parameters
path
- Type:
() => string - Required: Yes
Accessor that returns the path to resolve.
Return value
- Type:
() => string | undefined
Returns an accessor containing the resolved path, or undefined when the path cannot be resolved.
Behavior
- Resolves the current
path()value through the active route context. - Returns
undefinedwhen the path cannot be resolved.
Examples
Basic usage
import { A, useResolvedPath } from "@solidjs/router";
function SettingsLink() { const settingsPath = useResolvedPath(() => "settings");
return <A href={settingsPath() || ""}>Settings</A>;}