main
Branches
main (2.15.1)dev
Versions
2.15.11.19.3v0.21.0
React Router v7 has been released. View the docs
useParams

useParams

Returns an object of key/value pairs of the dynamic params from the current URL that were matched by the routes. Child routes inherit all params from their parent routes.

import { useParams } from "@remix-run/react";

function SomeComponent() {
  const params = useParams();
  // ...
}

Assuming a route like routes/posts/$postId.tsx is matched by /posts/123 then params.postId will be "123". Params for splat routes are available as params["*"].

Docs and examples licensed under MIT