useParams is a Client Component hook that lets you read a route’s dynamic parameters as filled in by the current URL.
app/example-client-component.tsx
Parameters
useParams takes no parameters.
Returns
An object containing the current route’s filled-in dynamic segments.- Each key is a dynamic segment name.
- Each value is a
string(for[param]) orstring[](for[...param]). - Returns an empty object
{}if the route has no dynamic segments. - Returns
nullwhen used in the Pages Router before the router is ready.
| Route | URL | useParams() |
|---|---|---|
app/shop/page.js | /shop | {} |
app/shop/[slug]/page.js | /shop/1 | { slug: '1' } |
app/shop/[tag]/[item]/page.js | /shop/1/2 | { tag: '1', item: '2' } |
app/shop/[...slug]/page.js | /shop/1/2 | { slug: ['1', '2'] } |
Example
app/product/[id]/edit/page.tsx
Version history
| Version | Changes |
|---|---|
v13.3.0 | useParams introduced. |
