useParams
Read the active path parameters.
Compatibility
ReactAvailable in this renderer's browser integration.
React SSRAvailable to this renderer's SSR integration; browser event handlers run after hydration.
PreactAvailable in this renderer's browser integration.
Preact SSRAvailable to this renderer's SSR integration; browser event handlers run after hydration.
Import from @kasperrt/smolter/react @kasperrt/smolter/preact
Signature
function useParams<
T extends Snapshot["params"] = Snapshot["params"],
>(): T;Parameters
No arguments.
Returns
A string-to-string parameter record.
Usage
Import this API from one of the entry points listed above. Keep server and build helpers in their dedicated subpaths.
const { id } = useParams();
return <p>Task {id}</p>;Behavior and edge cases
Named parameters are decoded; wildcard * captures the remaining path. Query strings are not params. Use useLocation or the loader Request URL for query values. It requires RouterProvider.